Вопрос

Let's say you have a menu that's the same for all pages of a website. Should you use client-side or server-side scripting for that?

Это было полезно?

Решение

I would generate it on the server side and cache it. Why make every browser do some work?

You can generate/output it with the same response for each page instead of having javascript make extra calls or cause the menu to only appear after the script finished running.

Другие советы

If it's repetitive content, I would do client-side script loaded via <script src=...> so that the repetitive content is separately cacheable to reduce the amount your users have to download. One caveat though, if your site has to work without javascript enabled, you obviously have to do it server-side.

With menus, you can also make the script deferred, so that it can download in parallel to the main content that your users came to the site to see.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top