Home > Article > Web Front-end > Perfectly solves the problem about preloading InstantClick
This article mainly introduces the solution to the problem of preloading InstantClick. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor to take a look.
During the transformation last night, the code highlighting could not be executed. To be precise, it was only executed once and not executed the second time. So I wrote an article to explain it, and after roughly reading the InstantClick documentation, I found that it is mainly a blacklist area issue. According to my personal understanding, the blacklist mainly includes two common filtering types, one is a tag and the other is js. According to its principle, the blacklist area is not processed (loaded and refreshed according to normal manual opening). This kind of non-processing can make the relevant structures and js work. .
So when InstantClick is executed, look at its reference statement:
##
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/instantclick.min.js" data-no-instant></script> <script data-no-instant>InstantClick.init();</script>The statement filters out InstantClick itself. It is equivalent to refreshing itself normally after execution.
<script data-no-instant> InstantClick.on('change', function() { // 回调 }); InstantClick.init(); </script>
a tag
8d81ca4b16c93367fc7a7a26af8a0e41this part will be refreshed as normal94b3e26ee717c64999d7867364b1b4a3.
data-no-instant attribute is used to prevent instantclick from repeatedly loading the element when the page switches (meaning to refresh normally). It can be used in script, style tags, or in a tags, which means that the link will be opened in the normal way without instantclick acceleration, but it is useless for p tags, which you must know.
The above is the detailed content of Perfectly solves the problem about preloading InstantClick. For more information, please follow other related articles on the PHP Chinese website!