什么是最有效的方式来隐藏网站的移动版本的内容? [英] What's the most efficient way to hide content for a mobile version of a site?

查看:117
本文介绍了什么是最有效的方式来隐藏网站的移动版本的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用大型网站的移动版本。

I'm working on a mobile version of a large site. There's a lot of content from the full site that's not needed for mobile.

隐藏这项功能的最佳方法是什么?

What is the best way to hide this? i.e. What will cause the least amount of work for the browser, so it stays responsive?


  • CSS显示:无

  • CSS display:none

jQuery的 .remove()方法,例如(未测试):

jQuery's .remove() method, for example (not tested):

var elements_to_remove = [
  '#sidebar',
  '#footer',
  '#etc'
];

$.each(elements_to_remove, function() {      
  if ($(this).length > 0) {
    $(this).remove();
  }
});


)是元素实际上从DOM树中删除,减少了内存使用。

The advantage I can see for .remove() is that the elements are actually removed from the DOM tree, reducing memory usage.

对于jQuery路由,是否有一个更好的事件挂钩到之前 document.ready? (即在DOM树形成时)。

For the jQuery route, is there a better event to hook on to before document.ready? (i.e. while the DOM tree is being made).

此外,有关如何对此进行基准测试的任何建议吗?

Also, any recommendations for how to benchmark this?

更新:提供自定义移动版本不是一个选项,它应该与现有内容一起使用/ 响应

Update: Providing a custom mobile version is not an option, it should work with the existing content / be 'responsive'.

推荐答案

不包括页面上的内容。

The most efficient way will be to not include the content on the page in the first place.

移动用户会感谢您不要在网页上没有显示的元素浪费他们的数据资费,如果他们不需要JavaScript来查看页面正确。

Mobile users will thank you for not wasting their data tariff with elements that are not shown on the page and will be happy if they don't need JavaScript in order to view the page correctly.

这篇关于什么是最有效的方式来隐藏网站的移动版本的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆