Javascript code in ads is broking my website

Posted in: Newspaper
Post count: 28

Hi! i added to custom ad 2 the following code:

<script type=”text/javascript”> var imagen = new Array(); var enlace = new Array();
//
// ANUCIO PROVINCIALES
// Ya supondrás que un par (imagen y enlace) por cada anuncio.
//

imagen[0] = “http://weekenjoy.com/wp-content/uploads/2018/05/blup-1.gif&#8221;;
enlace[0] = “https://www.facebook.com/bluphelado/&#8221;;

//
// A partir de aquí el restro del programa.
var xy; do { xy = Math.floor(Math.random()*imagen.length); } while(xy==window.ANUNCIO_ANTERIOR); window.ANUNCIO_ANTERIOR = xy; var img_width = “300”; var img_height = “250”; var img_title = “Visita el sitio web”; document.write(‘'+img_title+'‘);
</script>

This code allow me to use random pics that i use so in that way i can use local ads. If you go to the home http://www.weekenjoy.com the web loads heavy but loads… however if you want inside a post, the web never loads and it freeze the window. I tried to use another light image but that is not the problem, even if i use the script without images the posts freeze completely… Please, how can i use this script in my entire web without problems.

http://weekenjoy.com/tespero-sabado-12-de-mayo/

Post count: 28

<script type=”text/javascript”> var imagen = new Array(); var enlace = new Array();
//
// ANUCIO PROVINCIALES
// Ya supondrás que un par (imagen y enlace) por cada anuncio.
//

imagen[0] = “http://weekenjoy.com/wp-content/uploads/2018/05/blup-1.gif&#8221;;
enlace[0] = “https://www.facebook.com/bluphelado/&#8221;;

//
// A partir de aquí el restro del programa.
var xy; do { xy = Math.floor(Math.random()*imagen.length); } while(xy==window.ANUNCIO_ANTERIOR); window.ANUNCIO_ANTERIOR = xy; var img_width = “300”; var img_height = “250”; var img_title = “Visita el sitio web”; document.write(‘'+img_title+'‘);
</script>

posted again for a better view

Post count: 28

i deleted the js in custom ad2 because the website is unusable with that script…

Post count: 20688

Hi,

Indeed, loading some scripts in the theme ad spot section will cause problems. There have been cases where some scripts caused the images on the whole website to not display.

When this happens there would be no solution except to modify the ad code if possible, or use a different one.

Post count: 28

Any clue for how to modify?

Post count: 20688

Maybe ask the ad provider if possible if there is another version of the ad code. If you modify it yourself it may not display or work properly anymore.

Post count: 28

However i have another website with Newspaper 8 with older version and in this didn’t happens never… It’s the same version how can be this possible? Newspaper 8 is prepared to use custom ads, i don’t see any reason to work properly with custom ads in homepage but not in posts… This is clearly a problem of the theme and lastest updates…

Post count: 20688

From what I can see the moment that ad code and script is loaded in the website, and the post content is loaded as well eventually
https://www.screencast.com/t/idLSwKpA7d
But it is loading very bad, at least the post I tested. Seems you use some kind of gallery implementation or plugin to display images. These images that are served to users are quite big, the post I tested took 5 minutes to load fully and transferred a total of 183 MB content, which would be a very long time and enormous page size
https://www.screencast.com/t/9m5gYWTUEW

Post count: 28

yes finally i fixed the problem with that ad.
That page is an old post and the new ones are images very very tiny… Any suggestion to improve the results with this kind of post that are fully images of gallery?

Post count: 20688

Best to use smaller images if possible, or thumbnails of them
https://www.screencast.com/t/QJjwJHA0Sw1w
Also check online image optimization guides and tutorials, there are plenty
https://www.wpexplorer.com/optimize-images-wordpress-guide/
https://cyberchimps.com/guide/optimize-images-for-wordpress/

Post count: 28

Thanks, you can close this ticket. The problem with the script was a ” missed at the end of the image link (imagen[0])

Viewing 11 posts - 1 through 11 (of 11 total)
The forum ‘Newspaper’ is closed to new topics and replies.