简体   繁体   English

当我需要大量声音文件时,如何让我的网页快速加载?

[英]How do I get my webpage to load quickly when I need lots of sound files?

I'm pretty new to web design and I'm building a webpage for learning the Cherokee syllabary.我对网页设计很陌生,我正在构建一个网页来学习切诺基音节。 The main page is a table of 85 characters that plays the sound for the character when you click on one.主页是一个包含 85 个字符的表格,当您单击一个字符时,它会为该字符播放声音。 Currently I have all of the sound files stored in both .mp3 and .oog formats in a /sounds folder, and I put 85 different <audio> tags at the end of my html document, and play them using jQuery as shown below.目前,我将所有声音文件以 .mp3 和 .oog 格式存储在 /sounds 文件夹中,我在 html 文档的末尾放置了 85 个不同的<audio>标签,并使用 jQuery 播放它们,如下所示。 The page load time is okay on my laptop but on my phone it's really slow, and I assume this is because of all of the sound files.页面加载时间在我的笔记本电脑上还可以,但在我的手机上它真的很慢,我认为这是因为所有的声音文件。 How can I implement this in a way that loads the page more quickly?如何以更快地加载页面的方式实现这一点?

 $('td').click(function(){ var name = $(this).find('.tbl-en').html(); var tag = 'audio-' + name; var sound = document.getElementById(tag); sound.play(); });
 <audio id="audio-a"> <source src="sounds/a.mp3" type="audio/mp3"> <source src="sounds/a.oog" type="audio/oog"> </audio>

Don't set the src attribute until the user has clicked on that element.在用户单击该元素之前不要设置src属性。 Here is an example:下面是一个例子:

http://codepen.io/tevko/pen/raQMjP http://codepen.io/tevko/pen/raQMjP

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

相关问题 如果我需要将外部网址加载到网页中,是否可以使用iframe替代 - Are there any alternatives for an IFrame if I need to load an external url to my webpage 如何测试网页的性能 - How do I test the performance of my webpage 如何在网页加载时显示加载内容,并在页面完全加载时隐藏该内容? - How can I show load content while my webpage is loading and hide this content when the page is fully loaded? 如何获得不同的标签来加载单独的javascript文件? - How do I get different tabs to load separate javascript files? jQuery-如何仅在查看时加载计数器? - jQuery - How do I get my counter to load only when in view? 如何快速计算网页上字符串的出现次数? - How can I quickly count occurrences of a string on a webpage? 使用.load()更改divs内容时,是否需要重新添加脚本? - When using .load() to change a divs content do I need to re-include my scripts? 如何让 Materialise Feature Discovery Block 显示在我的网页上? - How do I get the Materialize Feature Discovery Block to show up on my webpage? 如何使用jquery ajax api加载包含大量图像和文本的php页面? - how do i load a php page with lots of image and text using jquery ajax api? 如何使jQuery在Typescript文件中工作? - How do I get jQuery to work in my Typescript files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM