简体   繁体   English

如何通过移动Web开发有效地利用资源?

[英]How to effectively use resources with mobile web development?

I am new to mobile web development and I'm trying to figure out the best structure. 我是移动Web开发的新手,我正在尝试找出最佳结构。 I have decided to use a sub domain to handle everything mobile with some JavaScript that points to that sub domain if it detects mobile. 我决定使用一个子域来处理所有移动内容,并带有一些JavaScript,如果该JavaScript可以检测到该内容,则指向该子域。

My JavaScript file points to http://m.mywebsite.com . 我的JavaScript文件指向http://m.mywebsite.com The sub domain is on the server at "root/mobile" so all the resources are mobile use can be grabbed there. 子域位于“根/移动”服务器上,因此可以将所有资源用于移动使用。

Here is my confusion: To use less resources and data, duplicate files I go back a directory. 这是我的困惑:为了使用更少的资源和数据,重复的文件我返回一个目录。 For example, to embed the logo image I would use src="../images/logo.png" . 例如,要嵌入徽标图像,我将使用src="../images/logo.png" Wouldn't this be correct? 这不正确吗? Is there any disadvantages to doing this? 这样做有什么不利之处吗? I don't see a point in make a new images directory and placing a copy of the logo in there as it would use more data. 我看不到建立新图像目录并在其中放置徽标副本的意义,因为它将使用更多数据。 Although, everywhere I look online people are making duplicate directories inside their mobile directory. 虽然,在我看来,到处都是在线人们在他们的移动目录中创建重复的目录。

Perhaps it doesn't matter and I'm overthinking this. 也许没关系,我对此进行了仔细考虑。 Or perhaps I'm looking in the wrong places... if this is the case, can someone provide useful links for starting out mobile use? 或者也许我在错误的地方寻找……如果是这种情况,有人可以提供有用的链接来开始移动用途吗?

Thank you!! 谢谢!!

I hope I get you right. 我希望我能对你。

Whether or not the general (not mobile) resources folder is in different domain/subdomain, you can, to be on the safe side, refer to that folder by specifying the full URL (as long as the client has access to it. see CORS), rather than the relative URL. 不管常规(非移动)资源文件夹是否位于其他域/子域中,为了安全起见,您可以通过指定完整URL来引用该文件夹(只要客户端可以访问它即可。请参阅CORS。 ),而不是相对网址。

src="http://m.mywebsite.com/images/logo.png"
src="http://m.mywebsite.com/mobile/images/logo.png"
src="http://mywebsite.com/images/logo.png"

Regarding images duplication, it is preferred to use smaller resolution copies of your desktop images for mobile versions. 关于图像复制,最好将较小分辨率的桌面图像副本用于移动版本。 Smaller images result in better scaling on smaller screens and better latency (as the files are smaller in size for download). 较小的图像可在较小的屏幕上实现更好的缩放比例,并具有更好的延迟(因为文件较小,可供下载)。

So if you use smaller images for mobile version, you have no duplication anyway. 因此,如果将较小的图像用于移动版本,则无论如何都不会重复。

Take into consideraion that mostly storage costs are much cheaper than network traffic costs. 考虑到大多数存储成本比网络流量成本便宜得多。 So it is mostly better to have an appropriate resource for every relevant case, than to worry about one more or less directory. 因此,与担心一个或多个目录相比,最好是为每个相关案例拥有合适的资源。

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

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