Home  >  Article  >  Web Front-end  >  Perfectly solves the problem about preloading InstantClick

Perfectly solves the problem about preloading InstantClick

巴扎黑
巴扎黑Original
2017-09-13 09:32:111992browse

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(&#39;template_directory&#39;); ?>/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.


Load and refresh js normally


The data-no-instant parameter of the statement itself means not to process it, and refresh this part of the structure normally. So if you want other js to work under InstantClick, you must refresh the js itself. You can write the code into instantclick.min.js, or you can use the data-no-instant parameter to reference it independently. If you do not write your own js into instantclick.min.js, you must use its four parameters to reload. Reference: http://instantclick.io/scripts



<script data-no-instant>
InstantClick.on(&#39;change&#39;, function() {
// 回调
});
InstantClick.init();
</script>

a tag

InstantClick does not process the a tag opened in a new window, and also has the data-no-instant parameter. The a tag under the tag package will not be processed either. For example,

8d81ca4b16c93367fc7a7a26af8a0e41this part will be refreshed as normal94b3e26ee717c64999d7867364b1b4a3.

Final summary: The

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.

It will be easier to handle after understanding the above two points. Previously, it was understood as ajax, which was requested by the entire body. In other words, it is also possible to put the unprocessed part outside the body tag.


It is worth mentioning that I personally like its cache backward and forward function, which is very fast.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn