Moving External Scripts

One of the problems with having external scripts on your site is that you have little control over them – caching and the like are out of your hands.

The solution I’m using, via cPanel, is a weekly cron job that copies external scripts to a folder on my own server. And it will only do this if the script has only changed, as well.

I’m no Linux expert (or probably even amateur, if I’m honest) so it took a while to find the right code to use, but here is the result…

wget -N  --directory-prefix=[local folder] [script location]

Simply change [local folder] to where you wish the script to be copied to and [script location] to where the external script is held (including script name). If you wish to perform multiple copies you can append them together with &&.

So an example may be…

wget -N  --directory-prefix=public_html/wp-content/themes/artiss  http://pagead2.googlesyndication.com/pagead/show_ads.js

This would copy the AdSense code show_ads.js to a theme folder named “artiss”.

In

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading