Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bobi 352 posts 966 karma points
    Apr 11, 2017 @ 03:12
    Bobi
    0

    CSS and JS Minification issues

    Hi there,

    Perhaps someone could help me understand an issue I am experiencing upon deployment of a site. It seems that on my local machine I don't have any CSS Minification and Javascript Minification issues with my web pages.

    However, once uploaded to a server running Microsoft Server 2012 R2, I seem to have CSS and Javascript Minification errors on all of my pages, which I did not have on my local machine.

    I'm thinking it is due to a discrepancy with the setup of my server compared to local machine, but not sure what exactly it is.

    Any ideas on how to configure the server properly or do anything else to avoid the CSS and Javascript Minification errors?

    Thanks :)

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Apr 11, 2017 @ 07:52
    Michael Latouche
    1

    Hi Bobi,

    Could you maybe give some more details about the kind of errors you are experiencing? Maybe also check in the JavaScript console of your browser if you don't have any error appearing there that might be of any help?

    CSS and JS being client-side matter, at first thought it should not be due to server settings or configuration.

    Also, maybe a silly question but are you sure you are testing locally with the minified versions? Because for example, if your are debugging from Visual Studio, by default there is no minification when you run in "debug mode". So you might be testing locally with unminified version and on your server with minified version... Which would then be an indication that somehow it is the minification process that creates an error (but then you can debug locally :-)).

    Hope this helps.

    Cheers,

    Michael.

  • Bobi 352 posts 966 karma points
    Apr 11, 2017 @ 15:56
    Bobi
    0

    Hi Michael,

    The errors I am experiencing were found through the SEO checker that I am using. On my local machine (through visual studio) on Microsoft Edge, there were no minification issues indicated.

    However, after deployment onto the local server running MS Server 2012 R2 in IIS 7, I'm getting minification errors running safari. I have a feeling it is some type of configuration issue with the server, but I really don't know.

    I am running things in Visual Studio, but in release mode. Any ideas of how to handle minification?

    I have already turned on dynamic compression on the server (for gzip).

    Cheers.

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Apr 12, 2017 @ 07:39
    Michael Latouche
    1

    Hi Bobi,

    Unfortunately I usually just let asp.net handle the minification by himself, so i cannot give a lot of advice on this. I also had a project where the minification was done via gulp tasks.

    I have already experienced minifications issues because of missing semi-colons in JS files for example, that is why I suggested to check for errors in the JS console of your browser.

    Is the error only happening in Safari on your server? Or in other browsers as well? And if it is only Safari, did you try locally on Safari?

    It could be interesting if you could post some extra details about what the minification error messages you get, it might help identify in which direction to investigate :-)

    Also, did you try to run the site on the server without minification? Just to make sure the error is not due to something else?

    Cheers,

    Michael

  • Bobi 352 posts 966 karma points
    Apr 12, 2017 @ 15:33
    Bobi
    0

    Thanks for the reply Michael.

    What I did was used the client dependency framework to pull the css files and then render them. This minified them automatically through asp.net (probably similar to what you do?).

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Apr 12, 2017 @ 15:34
    Nicholas Westby
    1

    A bit of a shot in the dark, but if you are using a tool that is checking on SEO, my guess is that you aren't getting a minification error, but you are instead getting a minification suggestion. It is common for these tools to recommend that you minify JavaScript/CSS files to make them smaller, which improves load time, which boosts SEO. I am not sure why it would vary across environments.

    However, if you instead mean compression (rather than minification), that is indeed a very common environment-specific setting that can be turned on and off. Typically, this means GZip compression.

    By the way, I don't think you should need to turn on dynamic content compression to GZip compress JavaScript and CSS files (I believe those are considered static content rather than dynamic content).

    If you have more details about the errors/suggestions you are seeing, perhaps we can assist further.

  • Bobi 352 posts 966 karma points
    Apr 12, 2017 @ 15:40
    Bobi
    0

    Hmm, that is a good point. I turned on dynamic compression in the server, thinking that this would help with GZip compression of images.

    Is there another way to turn on GZip?

    With respect to the css and js minification, it appeared that I was referencing 8 css files (the class html way) and 8 js files (again, the classic html way). The SEO tool was telling me that there were too many references and to consider minification (thus the "error"). I went back and used the client dependency framework to utilize asp.net's minification features.

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Apr 12, 2017 @ 15:48
    Nicholas Westby
    101

    To enable GZip compression, turn on static content compression and ensure JavaScript and CSS are in the <staticContent> element in the web.config (that second bit may be optional, as I think JS/CSS are defaults). Both of those are explained in the answers here: http://stackoverflow.com/questions/2510546/enabling-javascript-gzip-compression-in-iis

    You can also add this to the <staticContent> element to indicate the duration of caching:

    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
    

    In that case, it will cache for a year.

    By the way, if you are using the client dependency framework, you might then need to do dynamic content compression (not sure).

  • Bobi 352 posts 966 karma points
    Apr 12, 2017 @ 15:53
    Bobi
    0

    Hmm. Ok, I will take a dive into this.

    The server is telling me that dynamic content compression can slow down the server, blah, blah, blah, but I kept it on anyways (truly not sure if it helps).

    I'll report back!

  • Bobi 352 posts 966 karma points
    Apr 13, 2017 @ 18:24
    Bobi
    1

    Ok, I minified everything using client dependency, and left dynamic compression turned on in the server.

    This seemed to fix those so-called "errors".

    Thanks for that Nicholas.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies