October 22, 201213 yr Hi all, got a problem thats been driving me insane and would love some advice. So im using an image gallery plugin called 'Galleria', it has a nifty flickr plugin that allows me to make categorised galleries using sets from my clients flickr accounts. Everything works fine over WIFI but when viewed on 3G it doesnt load at all, I think it has to do with 3G providers changing JS files to inline. The funny thing is if I clear the cache (ctrl - shift - r on firefox) it then loads. the gallery is hosted at: http://sdsimprintedconcrete.co.uk/sdsgallery.html been trying to figure out the problem myself and read about 'Cache-Control:no-transform' but even though iv added it to my header im still having the same issue. Any help would be greatly appreciated.
October 23, 201213 yr Just had a look at the site and it has a javascript error. ReferenceError: bmi_load is not defined [http://sdsimprintedconcrete.co.uk/sdsgallery.html:239] Not sure if that might be the reason? Maybe if 3G providers are changing the js to inline it is stopping at the error or something? Try fixing the error and see what happens...
October 23, 201213 yr Author Right, with some searching on google i've found a solution... <script type="text/javascript"> // <![CDATA[ // Using document.write to load Javascript dependencies to bypass O2 network inlining of Javascript. function loadJS(file){document.write("<" + "script type='text/javascript' src='" + file + "'></" + "script>")} loadJS("/js/jquery-1.4.2.min.js"); loadJS("/js/myJSLibrary.js"); // ]]> </script> The code above prevents google from 'inlining' js code and messing stuff up. Kudos goes to 'Sroebuck' at StackOverflow http://stackoverflow.com/questions/3282373/web-site-exhibits-javascript-error-on-ipad-iphone-under-3g-but-not-under-wifi
October 23, 201213 yr Author I hope this bit of code helps anyone having problems with 3G providers changing their code! Sure helped me and wanted to pass on the solution.
October 24, 201213 yr I do this in htaccess, as recommended by O2. HTML5BP contains a snippet for this very purpose: # ---------------------------------------------------------------------- # Prevent mobile network providers from modifying your site # ---------------------------------------------------------------------- # The following header prevents modification of your code over 3G on some # European providers. # This is the official 'bypass' suggested by O2 in the UK. # <IfModule mod_headers.c> # Header set Cache-Control "no-transform" # </IfModule>
October 25, 201213 yr Author Wow, Thanks for that info inspired.. Didnt really understand htacces but just done a little research and think I understand it a little more (basically a text file uploaded to web server yes?) Also just checked out the html5bp and cant say thank you enough for bringing this amazing template to my attention! Saw it somewhere before but never really gave it much thought. Could you maybe give a helping hand or point me In the right direction for righting my own htacces files? Would like to use your method of preventing 3G from inlining my JS files. Thanks again for the insight mate
October 26, 201213 yr My pleasure. Mmm, kinda. htaccess can be used to set behaviours of Apache, and with it you can do tons of stuff that are pretty much like magic. URL re-writes is just the tip of the iceberg. The .htaccess file in HTML5BP is heavily commented, so just give that a good read through. Upload it to the root of your site and uncomment the parts you want to use. If you break something (500 err typically) go back a step. Writing your own is a taller order. As you can see from the HTML5BP example the syntax is not exactly crystal clear!
October 26, 201213 yr Bingo. Apache is controlled by its config file, httpd.conf. Some directives in httpd.conf can be overridden on a directory-by-directory basis by a .htaccess file placed in that directory, which will apply to that directory and any children (so if you have one in your root, the rules in it will apply to your whole site unless overridden again by a .htaccess file in a lower directory). Edited October 26, 201213 yr by Renaissance-Design
October 27, 201213 yr Author right so i have downloaded and had a good read of the html5bp, just to be clear to uncomment parts of the htaccess do i just remove the # from the parts I wish to use? Lots of usefull stuff within this boilerplate! Anyone who has yet to check it out I would suggest taking a look... Thanks again spired!
October 27, 201213 yr just to be clear to uncomment parts of the htaccess do i just remove the # from the parts I wish to use? Yup.
Create an account or sign in to comment