SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How Google and Facebook write javascript codes that are hard to read (view source)

    Hi guys,

    I wonder if I can achieve something like that too. Any idea for me to start my research?

    Thanks

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,196
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Something like the Google closure compiler will do this http://closure-compiler.appspot.com/home

  3. #3
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    thanks,
    not understand this but will give it a try

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Do you know server side code?

    <?php

    echo "var a,e,i,o,o;"

    echo "function doSomething(){"
    echo "alert();"
    echo "}"

    ?>
    Will output it all on one line
    <%

    response.write "var a,e,i,o,o;"

    response.write "function doSomething(){"
    response.write "alert();"
    response.write "}"

    %>
    Is the same for ASP

    In PHP you can use mod rewrite to keep using the .js extension.
    Remember to set the headers for content type javascript. Each server language is slightly different. Browsers are different in automatically detecting js if the header is not put in.
    You will also need to look in to cache headers too, as each browser acts differently, some even ignore the no-cache header completely. To get round this add a time variable to the URL when calling the server coded javascript
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •