dongyu1918 2019-07-18 00:08
浏览 58

为WordPress站点创建脚本重定向

I have 20 static components from Plugins and Theme for some reason cannot be seen by a Caching plugin because of issues like WP_CONTENT_URL instead of content_url(). Some apparent old style of PHP? Because of issues like this the caching plugin cannot rewrite the URLs as a static resource, cache it and have it served as a CDN pull resource. Going through all of the plugins and rewrite them, that will be a waste as soon as there is an update the change is gone.

My need is to figure out how to redirect each time a .js is requested it obtains the file from a different location. Example:

This is the location of one of the culprit files:

wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js 

I want it from here:

https://CDNHost.KXCDN.com/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js

I could probably do this in htaccess but I don't want 20 or more 301 or 302 redirects on the site.

Can all of the 25 scripts be included on one or more. None of the scripts I need to move a render blocking. One of my problems with this is I don't know js worth a darn.

I don't know how to intercept the request for the script in the original location & have it forgotten while getting the new location.

Can the Fetch Loading be used?

fetchInject([
  'https://CDNHoat.KXCDN.com/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js'
])

If I call the files as a preload:

<link rel="preload" 
href="New-file-location" as="script"

This does nothing with the original script call.

I hope some one else may have figured out how to do this. Or just flat out would share their knowledge to get me squared away.

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源