Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript problems on 3G

Featured Replies

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.

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...

  • 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

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>

  • 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

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!

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 by Renaissance-Design

  • 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!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.