Hello Creators, I am experimenting with a new feature for my network, however the JavaScripts are conflicting if the page takes too long to load. Is it possible to delay one of my scripts somehow?

Thanks everyone. Take care.

Tags: delay scripts

Views: 62

Reply to This

Replies to This Discussion

If someone can teach me how to delay a script from loading, I will release an amazing TIP.

What TIP you ask?

How about letting your members choose what style sheet they prefer (light/dark/holiday) and have a cookie remember their choice?

It's possible, I've had it working (not easy) but my problem is that it conflicts with my jquery tabs. So I need to delay the styleswitcher script so that there are not these conflicts.

Thanks guys, I'd love some help.

I'm pretty sure that this is close to the right track....

Needs a bit of altering, and I need to learn where I am to implement this, and how to apply it to my styleswitcher script.

onClick="setTimeout(function() {alert('hello');},1250);

Wouldn't want the alert part, but the timing delay function is there. 1250 milliseconds.

So this gives a delayed pop up message. How do I convert this to happen for my styleswitcher script, without the pop up of course.

<form>
<input type="button" value="Push this button to open an alert box in 1250 milliseconds" onClick="setTimeout(function() {alert('hello');},1250);">
</form>

There's also a small issue with my styleswitcher script. I'll address that if I end up posting the TIP. It's pretty advanced in my opinion.

Seems that on the first stylesheet, everything is fine, then switch to stylesheet 2, and my ningbar no longer is fixed, and that whole top section is wacky.

I know you all won't have a clue what I'm talking about, until you see the scripts.

Perhaps I'll just post the TIP and see what happens.

Hi Damien ,

i normally use jQuery to do this :

This script is to wait the window to complete loading then carry out the javascript

$(window).load(function(){

   //javascript code goes here.

});

Awesome Elson, that looks like it would work beautifully, and even looks easy to implement... now can I just delay the call to the script?

$(window).load(function(){

<link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" />

});

That's my stylesheet, I know, but will it work like this?

Do it like this:

$(window).load(function(){

   $('head').append('<link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" />');

});

Ok sorry Elson, this is easier... this is what I need to delay... could you copy and paste, and add the delay for me? I'm failing my attempts.

<!--trial stylesheet switcher-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    
    <link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" title="styles1" media="screen" />
    <link rel="alternate stylesheet" type="text/css" http://api.ning.com/files/6dRGUjTYClcg8NTa4pZGB8sk7LHCbUboLSQ0qY74i...*fJoxnvqgv7/APStyleSheetdark.css" title="styles2" media="screen" />
    <link rel="alternate stylesheet" type="text/css" href="http://api.ning.com/files/j4wABojellApIBhmYmDsM277fce8Nxo89VvZ-RBKHE*TIWgXmeZQdVXrmacxm--bxgjgmBoGhEE76hH4ZbVfclB9ARHpD33o/NewStyleSheet1.css" title="styles3" media="screen" />
    
    <script type="text/javascript" src="http://api.ning.com/files/Xa61raAgaMBP4H-8-Nc9KCD2YeF5sKcEoyVrvYDGNewp*wpk1kDvcxeOj4-P8QaBuexl5Z5xIQnpjf2fYOUvLUChg-Z2PJ-1/jquery.js"></script>
    <script type="text/javascript" src="http://api.ning.com/files/2FXMAzoleHRH0bqbUZH1ozOC1B6qKpG*LcKJEUHCNnDFMRnIOLmRfB*-vtfCin-wBGBVvz44um8VS4E0LjoVF9K8llOoqOw3/Styleswitch.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<!--end trial stylesheet switcher-->

Also, you know my fixed ningbar? When I switch to 2nd and 3rd stylesheet, the ningbar is no longer fixed, and all of the stuff in the ningbar is no longer in there. (account module returns to left column, navigation is no longer in ningbar, and ningbar is no longer widened. Seems like the stylesheets don't fully load or something? Not sure if you'll know an answer for this, and I may have to design the 2nd and 3rd stylesheets to not have a fixed ningbar, and think up something different.

I have just used this to delay cometchat loading, because it was conflicting with my jquery tabs.

For those who are using the tquery tabs, have you noticed that almost every script conflicts with the tabs?

Anyways, I was able to make my site way faster by delaying the one script. Amazing how much time it takes up, when the internet is confused. lol

Thank you Elson, I'm awaiting your message when you are available for my hire.

RSS

Latest Activity

Profile IconNing via Facebook
Thumbnail

Are you betting your community's growth on "sometimes" and "maybe?"…

See More
Facebook7 minutes ago · Reply
Profile IconAnh Khé Phùng and Christy C. joined Creators
8 minutes ago
Gary W Norman replied to Gary W Norman's discussion 'Tagline Font Size or Type - can it be changed?'
"it's too bad I can't upload my own png file, but as for fonts; either Birmingham , or…"
9 minutes ago
Kos replied to Gary W Norman's discussion 'Tagline Font Size or Type - can it be changed?'
"Sure can but the question is, what font do you wish to use (?) and do you want it normal, bold or…"
12 minutes ago
Gary W Norman replied to Gary W Norman's discussion 'Tagline Font Size or Type - can it be changed?'
"So am I Kos and thanks again for your help! ..and thanks to James too!  Now let me ask…"
38 minutes ago
Yaron replied to Allison Leahy's discussion 'Changes to Ning 3.0 Based on Your Feedback'
"Thank you"
1 hour ago
Allison Leahy replied to Allison Leahy's discussion 'Changes to Ning 3.0 Based on Your Feedback'
"Thanks, Yaron. Happy to communicate your feedback regarding fullscreen video embeds back to the…"
1 hour ago
Allison Leahy replied to SM's discussion 'Just discovered Disqus commenting on Ning - how do we add more features?'
"Not quite clear what Jon is stating here. It reads to me as though a Disqus user can simply login…"
1 hour ago

© 2013   Created by Ning.

Badges  |  Report an Issue  |  Terms of Service