Catégories
Technologie

Comment optimiser Amazon Affiliate JS avec le plugin WordPress LiteSpeed Cache

Did you enable ‘Load JS Deferred‘ in the LiteSpeed Cache Page Optimization, WordPress Plugin? I don’t believe the Amazon Affiliate JS likes being deferred. Trust issues? Optimize Amazon Affiliate JS with LiteSpeed:

Go to LiteSpeed Cache => Page Optimization => [7] Tuning Settings

Scroll down until you see ‘JS Deferred Excludes’.

Add a line like:

 z-na.amazon-adsystem.com/widgets/onejs

Go to LiteSpeed Cache => Page Optimization => [3] Optimization Settings

Scroll down until you see ‘DNS Prefetch’.

Add a line like:

//z-na.amazon-adsystem.com

Go to LiteSpeed Cache => Toolbox => [1] Purge (default) => Click on Empty Entire Cache

Clears all cache entries related to your site, including other web applications. This should only be used if things are cached incorrectly.

If you also use Cloudflare Rocket Loader, you need to change your code:

<script type="text/javascript">
amzn_assoc_tracking_id = "YourAmazonTrackingID";
amzn_assoc_ad_mode = "manual";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_design = "enhanced_links";
amzn_assoc_asins = "B08JGX61H7";
amzn_assoc_placement = "adunit";
amzn_assoc_linkid = "048bc2065ee4ca44aa99035a2a844837";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>

TO:

<script data-cfasync="false" type="text/javascript">
amzn_assoc_tracking_id = "YourAmazonTrackingID";
amzn_assoc_ad_mode = "manual";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_design = "enhanced_links";
amzn_assoc_asins = "B08JGX61H7";
amzn_assoc_placement = "adunit";
amzn_assoc_linkid = "048bc2065ee4ca44aa99035a2a844837";
</script>
<script data-cfasync="false" src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>

This fixed my website. Hopefully it helps someone else from having to disable JD Deferred completely and lose the performance benefits of the optimization.

Par Graydon Schwartz

Pour en savoir plus sur Graydon, consultez le site À propos de moi page.