Load Random JS File When Page Refresh
2018-06-30, 09:03 AM,
#1
I'm working on new website that I need to load different JS file every time the page refresh, kind of split test.
Searching around the web and found some, no work.
I found the method on this page of stakeoverflow: https://stackoverflow.com/questions/3591...ge-refresh
Code:
<link href="/styles/<?php echo mt_rand(1, 5); ?>.css" rel="stylesheet" type="text/css"/>
look like it will work for js too. But I dont know php at all.

How can I load random js file every time the page refresh?
let's I have abc.js, every.js, well.js, notable.js and I want to load them randomly.
Many thanks.
Reply
Share This Thread :

2018-06-30, 09:34 AM,
#2
You should consider the following topics first, before you start to implement something like this:

- What happens if the same visitor returns? (solution: cookies [bad], session handling [good])
- How to handle/bypass the browser cache?
- How to handle/bypass possible proxy caches?
- AdBlockers/AV tools could detect your current method as spam/malware/...

.

My latest thread: 3 to 5 Million US$ revenue



[Image: giphy.gif]

Automate your daily work with Bots!
Then you'll have more time to sleep. ;-)
Reply
2018-06-30, 11:15 AM,
#3
(2018-06-30, 09:03 AM)immart247 Wrote: I'm working on new website that I need to load different JS file every time the page refresh, kind of split test.
Searching around the web and found some, no work.
I found the method on this page of stakeoverflow: https://stackoverflow.com/questions/3591...ge-refresh
Code:
<link href="/styles/<?php echo mt_rand(1, 5); ?>.css" rel="stylesheet" type="text/css"/>
look like it will work for js too. But I dont know php at all.

How can I load random js file every time the page refresh?
let's I have abc.js, every.js, well.js, notable.js and I want to load them randomly.
Many thanks.

$jsAr = ["abc.js", "every.js", "well.js", "notable.js"];
$js = $jsAr[array_rand($jsAr)];

<link href="/styles/<?php echo $js; ?>" rel="stylesheet" type="text/css"/>
Reply
2018-06-30, 11:46 AM,
#4
(2018-06-30, 11:15 AM)tirycm Wrote:
(2018-06-30, 09:03 AM)immart247 Wrote: I'm working on new website that I need to load different JS file every time the page refresh, kind of split test.
Searching around the web and found some, no work.
I found the method on this page of stakeoverflow: https://stackoverflow.com/questions/3591...ge-refresh
Code:
<link href="/styles/<?php echo mt_rand(1, 5); ?>.css" rel="stylesheet" type="text/css"/>
look like it will work for js too. But I dont know php at all.

How can I load random js file every time the page refresh?
let's I have abc.js, every.js, well.js, notable.js and I want to load them randomly.
Many thanks.

$jsAr = ["abc.js", "every.js", "well.js", "notable.js"];
$js = $jsAr[array_rand($jsAr)];

<link href="/styles/<?php echo $js; ?>" rel="stylesheet" type="text/css"/>
this works for me. rep+
thank you very much.
Reply


Related Threads
Thread Author Replies Views Last Post
  Do the language in landing page has to be the same language as GEO location? SupremeWarrior 4 127 2018-08-11, 10:57 PM
Last Post: PBNmaster
  What do you use to create a Landing Page? grahammiranda13 2 220 2018-07-21, 08:53 AM
Last Post: affmarketer101
  create landing page on blogge outgllat 1 167 2018-07-03, 03:34 PM
Last Post: CharlieHarper
  CPA Build Landing Page Locker Replacement hardslol 2 500 2018-06-21, 06:05 PM
Last Post: IM2020
  Where can I get this H@ck Landing page? immart247 10 1,259 2018-06-17, 11:17 AM
Last Post: CharlieHarper





About Us | Contact Us | CPA Elites | Advertise | Stats

© 2013-2018 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top