Change template_directory to use a CDN path

Posted on 16th September, 2015 152 Comments

So you’ve created your theme and you would like to switch to using a CDN for your scripts and CSS…

Add this to your functions.php and replace the YOUR-SITE with the urls of the website and the CDN.

add_filter( 'template_directory_uri', function( $template_dir_uri ){
return str_replace( 'http://www.YOUR-SITE.co.uk/', '//cdn.YOUR-SITE.co.uk/', $template_dir_uri );
});

Comments

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]

JamesVen

20th, Oct, 20

be a outstrip urgently fitted the next legit and Mawkishness [url=https://ciamedusa.com/]cialis from canada[/url] Owekek qfiwwt cialis effective buying cialis online safely

JamesVen

21st, Oct, 20

propagation: To delays the device go along an allergist of. [url=https://ciamedusa.com/#]generic cialis india[/url] and misinterpreting them its compromises to position statement

카지노사이트

07th, Jan, 21

Thanks again for stopping by, Solanski. Hope you’re having a great weekend.
You know, “trying not to sound like an idiot” is a pretty decent approach to commenting. If only every commenter took that approach! Haha.
카지노사이트

hey

13th, Jan, 21

Taxi moto line
128 Rue la Boétie
75008 Paris
+33 6 51 612 712  

Taxi moto paris

Pretty! This was an incredibly wonderful article.
Thank you for providing these details.

vreyrolinomit

17th, Jan, 21

Hmm it appears like your website ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to everything. Do you have any recommendations for beginner blog writers? I’d certainly appreciate it.

Lcxeloks

21st, Jan, 21

viagracanada viagra canada pfizer viagra [url=http://genqpviag.com/]where can i buy viagra in ireland[/url] ’

KbbtBoth

24th, Jan, 21

cheap. generic cialisis Lotensin best price for cialis 20 mg [url=https://xz-pharmacyonline.com]canadian drugstore[/url] ’

froleprotrem

28th, Jan, 21

I have been checking out some of your posts and i can claim clever stuff. I will surely bookmark your site.

부산달리기

03rd, Feb, 21

I?m amazed, I have to claim. Truly rar부산달리기
ly do I come across a blog that?s both educative as well as amusing, and also let me inform you, you have actually hit the nail on the head. Your suggestion is exceptional; the concern is something that not nearly enough individuals are speaking smartly about. I am very happy that I came across this in my look for something connecting to this.

froleprotrem

05th, Feb, 21

Hiya very cool web site!! Guy .. Excellent .. Superb .. I will bookmark your site and take the feeds additionally?KI’m happy to search out a lot of useful information here in the publish, we’d like develop more strategies in this regard, thanks for sharing. . . . . .

antivirüslere yakalanmayan php shell

08th, Feb, 21

When I originally commented I clicked the “Notify me when new comments are added”
checkbox and now each time a comment is added I get several emails with the same comment.
Is there any way you can remove me from that service?
Thanks!

vreyro linomit

08th, Feb, 21

Hello! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone. I’m trying to find a theme or plugin that might be able to correct this issue. If you have any recommendations, please share. Thanks!

Ybacroli

13th, Feb, 21

texas department of health & – cialis generic Aagilvz
does cialis for women work
cialis price compared to viagra: [url=https://www.withoutbro.com/]viagra for sale[/url]

Google

26th, Feb, 21

Google

Here are some links to web pages that we link to due to the fact we think they’re worth visiting.

Google

18th, Mar, 21

Google

Please check out the web sites we follow, including this 1, because it represents our picks in the web.

buy herbal incense online

27th, Mar, 21

buy herbal incense online

[…]please take a look at the internet sites we stick to, like this one particular, as it represents our picks in the web[…]

thc vape juice

31st, Mar, 21

thc vape juice

[…]The facts mentioned within the post are several of the most effective accessible […]

canada vs usa

01st, Apr, 21

canada vs usa

[…]below you will uncover the link to some web-sites that we assume you must visit[…]

virtual card buy

05th, Apr, 21

virtual card buy

[…]we came across a cool website that you could possibly take pleasure in. Take a appear should you want[…]

Mario kart Arcade Gp Dx

06th, Apr, 21

Mario kart Arcade Gp Dx

[…]check below, are some totally unrelated web sites to ours, on the other hand, they’re most trustworthy sources that we use[…]

Copper ring

06th, Apr, 21

Copper ring

[…]here are some links to internet sites that we link to due to the fact we consider they may be really worth visiting[…]

web landing page

08th, Apr, 21

web landing page

[…]check beneath, are some entirely unrelated internet sites to ours, nonetheless, they may be most trustworthy sources that we use[…]

buy delta 8 THC

09th, Apr, 21

buy delta 8 THC

[…]below you will obtain the link to some web pages that we consider you’ll want to visit[…]

where to buy delta 8

09th, Apr, 21

where to buy delta 8

[…]that is the finish of this report. Right here you’ll come across some internet sites that we believe you’ll appreciate, just click the hyperlinks over[…]

DEXACORTYLE FOR SALE

11th, Apr, 21

DEXACORTYLE FOR SALE

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless definitely worth taking a search, whoa did one master about Mid East has got extra problerms also […]

cheap cocaine for sale

11th, Apr, 21

cheap cocaine for sale

[…]very couple of web sites that transpire to be in depth below, from our point of view are undoubtedly nicely really worth checking out[…]

우리카지노

13th, Apr, 21

우리카지노

[…]just beneath, are numerous absolutely not related sites to ours, having said that, they may be surely really worth going over[…]

코인카지노

13th, Apr, 21

코인카지노

[…]please take a look at the web-sites we adhere to, including this one particular, because it represents our picks in the web[…]

Cryptocurrency

16th, Apr, 21

Cryptocurrency

[…]Every after in a even though we choose blogs that we read. Listed beneath are the most up-to-date web-sites that we choose […]

Vidalista 40mg

16th, Apr, 21

Vidalista 40mg

[…]just beneath, are quite a few entirely not associated internet sites to ours, nevertheless, they are surely really worth going over[…]

buy guns online

17th, Apr, 21

buy guns online

[…]here are some hyperlinks to websites that we link to simply because we think they are worth visiting[…]

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]