#1
  1. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2

    Minifying a JaveScript File


    Google Page Speed Insights recommends that I minify a few of my site's JavaScript files to improve on download speed and save on
    on file transfer size.

    Looking through the Google Developers website, it recommends using Closure Compiler ( https://developers.google.com/closure/compiler/ )
    among a few other tools to minify the JavaScript files.

    My question is, once I minify the file using the Web Application of Closure Compiler for example, or any other similar tool, is it as easy as deleting my
    original "un-minyfied" JavaScript file, and replacing it with my new "minifyed" JavaScript file on my hosting server?
  2. #2
  3. Just a Photographer
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    May 2011
    Location
    Atwater, CA
    Posts
    664
    Rep Power
    1096
    Depending on your site you can save a minified version and use that. I use WordPress and my theme looks for the minified version first, like 'style.min.css' or 'myJavascript.min.js'.

    I would NOT delete the originals though.
    Last edited by Hikin Mike; Jan 30th, 2016 at 05:08 PM.
    - Mike

    Jack of all trades, master of none.
  4. #3
  5. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2
    Originally Posted by Hikin Mike
    Depending on your site you can save a minified version and use that. I use WordPress and my theme looks for the minified version first, like 'style.min.css' or 'myJavascript.min.js'.

    I would NOT delete the originals though.
    Thanks. My site is not a wordpress site ( Although good to know that some WP themes look for the .min.js versions first ).
    My site is a typical html,CSS,js etc.. built site.

    Thanks in advance.
  6. #4
  7. Super Moderator
    SEO Chat Good Citizen (1000 - 1499 posts)

    Join Date
    May 2015
    Location
    United Kingdom
    Posts
    1,205
    Rep Power
    1711
    Originally Posted by BrownBag
    My question is, once I minify the file using the Web Application of Closure Compiler for example, or any other similar tool, is it as easy as deleting my
    original "un-minyfied" JavaScript file, and replacing it with my new "minifyed" JavaScript file on my hosting server?
    Yes it is, I would keep a copy of the original on my server which I would do edits on, then would minify and upload. This means you are able to easily read your code. However you could also use: unminify.com to unminify it too.
    Always happy to help in private message. | Freelance SEO https://thomasharvey.me
    Useful Links: Useful SEO Tools | Wordpress Hosting | Magento Hosting | FileOptimizer | Cloudflare
  8. #5
  9. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2
    Originally Posted by ThomasHarvey
    Yes it is, I would keep a copy of the original on my server which I would do edits on, then would minify and upload. This means you are able to easily read your code. However you could also use: unminify.com to unminify it too.
    Thanks. May be a dumb question, but I will ask anyway:
    If I minify the code, is there a need to change the file name to *.min.js ( Adding the ".min " in the file name )?
    Is there a possibility that some online "minifiers" may break the code?
    Thanks again.
  10. #6
  11. Just a Photographer
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    May 2011
    Location
    Atwater, CA
    Posts
    664
    Rep Power
    1096
    Originally Posted by BrownBag
    Thanks. May be a dumb question, but I will ask anyway:
    If I minify the code, is there a need to change the file name to *.min.js ( Adding the ".min " in the file name )?
    Is there a possibility that some online "minifiers" may break the code?
    Thanks again.
    No you don't have to add '.min' to it.

    Yes, It is possible that some minifiers may break the code.
  12. #7
  13. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2
    Gotta love those code breakers eh

    Thanks
  14. #8
  15. Super Moderator
    SEO Chat Good Citizen (1000 - 1499 posts)

    Join Date
    May 2015
    Location
    United Kingdom
    Posts
    1,205
    Rep Power
    1711
    Originally Posted by BrownBag
    Gotta love those code breakers eh

    Thanks
    Just to note, i've never had a minified file break on me (if you're doing to a sensible level such as removing spaces/line breaks, some do go as far as removing characters etc which is where things could get strange)
  16. #9
  17. Just a Photographer
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    May 2011
    Location
    Atwater, CA
    Posts
    664
    Rep Power
    1096
    Originally Posted by ThomasHarvey
    Just to note, i've never had a minified file break on me (if you're doing to a sensible level such as removing spaces/line breaks, some do go as far as removing characters etc which is where things could get strange)
    Me either.

    Combining several different JS files into one file may break though.
  18. #10
  19. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2
    Originally Posted by ThomasHarvey
    Just to note, i've never had a minified file break on me (if you're doing to a sensible level such as removing spaces/line breaks, some do go as far as removing characters etc which is where things could get strange)
    Thanks. Any particular online minifiers you would recommend?
  20. #11
  21. Just a Photographer
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    May 2011
    Location
    Atwater, CA
    Posts
    664
    Rep Power
    1096
    Originally Posted by BrownBag
    Thanks. Any particular online minifiers you would recommend?
    I use 'cssminifier.com' and 'javascript-minfier.com'.
  22. #12
  23. Super Moderator
    SEO Chat Good Citizen (1000 - 1499 posts)

    Join Date
    May 2015
    Location
    United Kingdom
    Posts
    1,205
    Rep Power
    1711
    Originally Posted by Hikin Mike
    I use 'cssminifier.com' and 'javascript-minfier.com'.
    Funnily javascript-minifier.com doesn't have a redirect, it's now: https://javascript-minifier.com/

    Those are both good quality minifiers.
  24. #13
  25. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2015
    Posts
    58
    Rep Power
    2
    Originally Posted by ThomasHarvey
    Funnily javascript-minifier.com doesn't have a redirect, it's now: https://javascript-minifier.com/

    Those are both good quality minifiers.
    Thanks guys for the input!

Similar Threads

  1. Index file redirected to a different file via 301
    By rocki in forum New User SEO Questions and Answers
    Replies: 1
    Last Post: Dec 16th, 2014, 04:28 PM
  2. When we add any file in robots.txt. then why disallow file display at SERP?
    By smyth in forum New User SEO Questions and Answers
    Replies: 2
    Last Post: Jun 22nd, 2014, 09:16 PM
  3. Removing file extentions without HTaccess. Does SE care about file-names?
    By Florence1 in forum Search Engine Optimization
    Replies: 0
    Last Post: Feb 2nd, 2013, 07:01 AM
  4. Replies: 0
    Last Post: Sep 7th, 2010, 11:01 AM
  5. Javescript VS. RSS; also no-cache?
    By juiced in forum Google Optimization
    Replies: 6
    Last Post: Apr 24th, 2005, 01:34 PM

IMN logo majestic logo threadwatch logo seochat tools logo