The first method means longer loading times since you have to load everything on the site up front, and it's totally broken for people who have disabled Javascript or whose browsers don't support it. The second method means the user only has to load the content they are actually looking at, and it should work even with non-Javascript browsers.
The advantage of the method would be speed, when navigating you don't need a round-trip to the server.
It also has a couple of disadvantages the main ones are; You can only link to the front-page, not directly to for example the about page because it doesn't have a separate url.
The back button in the user's browser won't work anymore.
The Advantages of the Javascript solution are mainly that you dont need to reload the page which is very nice for the user.
On the other hand you have the visitors with javascript disabled who wont be able to load the different pages. Also you cannot navigate over Javascript pages with the browser's back and forth buttons.
The last thing I see is that your code could become messy if you're not very careful and organized.
发布评论
评论(5)
第一种方法意味着更长的加载时间,因为您必须预先加载网站上的所有内容,并且对于禁用 Javascript 或浏览器不支持它的人来说,它完全无法使用。第二种方法意味着用户只需加载他们实际正在查看的内容,并且即使在非 Javascript 浏览器中也应该可以使用。
The first method means longer loading times since you have to load everything on the site up front, and it's totally broken for people who have disabled Javascript or whose browsers don't support it. The second method means the user only has to load the content they are actually looking at, and it should work even with non-Javascript browsers.
第一种方法的主要缺点是:
The main disadvantages that comes to mind for the first method are:
该方法的优点是速度快,导航时不需要往返服务器。
它也有一些缺点,主要是:
您只能链接到首页,而不能直接链接到“关于”页面,因为它没有单独的 URL。
用户浏览器中的后退按钮将不再起作用。
The advantage of the method would be speed, when navigating you don't need a round-trip to the server.
It also has a couple of disadvantages the main ones are;
You can only link to the front-page, not directly to for example the about page because it doesn't have a separate url.
The back button in the user's browser won't work anymore.
Javascript解决方案的优点主要是不需要重新加载页面,这对用户来说非常好。
另一方面,禁用了 javascript 的访问者将无法加载不同的页面。此外,您无法使用浏览器的后退按钮在 Javascript 页面上导航。
我看到的最后一件事是,如果您不非常小心和组织,您的代码可能会变得混乱。
The Advantages of the Javascript solution are mainly that you dont need to reload the page which is very nice for the user.
On the other hand you have the visitors with javascript disabled who wont be able to load the different pages. Also you cannot navigate over Javascript pages with the browser's back and forth buttons.
The last thing I see is that your code could become messy if you're not very careful and organized.
SEO 的一方面 - Googlebot 可能只会索引主页,而您的其他页面对搜索引擎来说实际上是不可见的。
SEO for one thing - Googlebot will likely only ever index the home page, and your other pages will be effectively invisible to search engines.