1

I'm working on a mobile web site wherein I pull in elements, using Xpath, from a parent site/domain and recreate them on a different domain. The trouble is that most of the elements that I pull in have inline styles attached by the Dojo JS framework. I tried removing these styles using this jQuery code

$('#elementID').removeAttr('style');

and it seems to work fine while the page is loading but once the page finishes loading the Dojo scripts attach the inline styles again. I read here that cross-domain scripts are loaded after the scripts of the site itself. Nonetheless, is there any way to control the script loading order?

Community
  • 1
  • 1
Mukul
  • 17
  • 4

3 Answers3

0

Try Google Loader.

Google Loader Developer's Guide In order to use the Google APIs, you must import them using the Google API loader in conjunction with the API key. The loader allows you to easily import one or more APIs, and specify additional settings (such as language, location, API version, etc.) applicable to your needs. In addition to the basic loader functionality, savvy developers can also use dynamic loading or auto-loading to enhance the performance of your application.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
0

You could put your script at the onload handler:

$(document).ready(function() {
  $('#elementID').removeAttr('style');
});

It executes after all other scripts are loaded

Paco Valdez
  • 1,915
  • 14
  • 26
0

You can try the defer attribute:

<script defer src="my-script.js"></script>

my-script.js:

  $('#elementID').removeAttr('style');
Esailija
  • 138,174
  • 23
  • 272
  • 326