简体   繁体   English

在鼠标悬停时加载javascript链接?

[英]Make javascript links load on mouseover?

I got a page on my website, that contain a table with a lot of tooltips.我在我的网站上有一个页面,其中包含一个带有很多工具提示的表格。 The tooltips are "offered" by wowhead.com.工具提示由 wowhead.com “提供”。 The problem is the loading time - takes forever to completely load the page (because of the tooltips) and the page is kinda "locked" until they are done loading.问题是加载时间 - 完全加载页面需要很长时间(因为工具提示)并且页面在加载完成之前有点“锁定”。

Demo link: https://wowpug.net/pug/HQDCXJWSTV演示链接: https : //wowpug.ne​​t/pug/HQDCXJWSTV

Example code:示例代码:

<a href="https://classic.wowhead.com/item={{ $softreserves[0]['item_id'] }}" data-wowhead="item={{ $softreserves[0]['item_id'] }}" target="_blank">
                    {{ $softreserves[0]['item_name'] }}
                </a>

I then came a cross another website, doing almost the same as me, but his tooltips load on mouseover instead of pageload.然后我来到另一个网站,做的几乎和我一样,但他的工具提示加载鼠标悬停而不是页面加载。 Demo: https://softres.it/raid/8vyko4演示: https : //softres.it/raid/8vyko4

I think that is a very smart way to to do, and the page loads extremely fast.我认为这是一种非常聪明的做法,而且页面加载速度非常快。

Not sure what he is doing and find it hard to research something i dont understand.不知道他在做什么,发现很难研究我不明白的东西。 Like what search-terms to use etc.像使用什么搜索词等。

Hope some of you guys can help me out here :)希望你们中的一些人可以在这里帮助我:)

Link to documentation on wowhead.com : https://www.wowhead.com/tooltips链接到 wowhead.com 上的文档: https ://www.wowhead.com/tooltips

In the inspector dev tools (in my example it's chrome) you can see that your website fetches the tooltip data for all the items at the same time在检查器开发工具(在我的示例中是 chrome)中,您可以看到您的网站同时获取所有项目的工具提示数据在此处输入图片说明

Try to click on to the initiator of a request (4th column - basic.js...) and see when the request is happening.尝试单击请求的发起者(第 4 列 - basic.js...)并查看请求何时发生。 You can go up the callstack and see what sequence of actions triggers the request.您可以向上调用堆栈并查看触发请求的操作序列。 So your goal is to make that request on "mouseover" event, not when the row is initialized.因此,您的目标是在“鼠标悬停”事件上发出请求,而不是在行初始化时发出请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM