Skip to Content
Vueを学ぶ
book

Vueを学ぶ

by Maya Shavin
March 2025
Intermediate to advanced
350 pages
5h 20m
Japanese
O'Reilly Media, Inc.
Content preview from Vueを学ぶ

第13章. Vueによるサーバ側レンダリング

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

前の章では、Vueアプリケーションの完全なCI/CDパイプラインをセットアップする方法を学んだ。また、Netlifyを使ってアプリケーションを本番用にデプロイする方法も学んだ。我々のアプリケーションは、ユーザがウェブ経由でアクセスできるようになった。これで、Vueを学ぶ旅はほぼ終わった。この章では、Vueを使用するもう一つの側面である、Nuxt.js を使用したサーバ側レンダリングと静的サイト生成を探求する。

Vueのクライアントサイド・レンダリング

デフォルトでは、Vueアプリケーションはクライアントサイドレンダリング用で、プレースホルダindex.html ファイル、JavaScriptファイル(通常はパフォーマンス最適化のためにViteによってチャンクにコンパイルされる)、CSS、アイコン、画像などの他のファイルによって、完全なUIエクスペリエンスが実現される。初期化ロードでは、ブラウザはサーバにindex.html ファイルを要求する。その代わり、サーバはオリジナルのプレースホルダ・ファイル(多くの場合、Vueエンジンがアプリ・インスタンスをマウントするための一意のidセレクタapp を持つ単一の要素)と、メイン・コードを含む必要なJavaScriptファイルを指すscript タグを配信する。ブラウザがHTMLファイルを受信すると、解析が開始され、目的のmain.js ファイルなどの追加リソースが要求され、それを実行して残りのコンテンツが適宜レンダリングされる(図13-1)。

Screenshot of a HTML placeholder file containing a single div with id of app, and a script tag containing the main code
図13-1. クライアント側Vueアプリケーションのレンダリングの流れ

この時点でアプリケーションの初期化が完了し、ユーザはアプリケーションとの対話を開始できる。Vueは、組み込みのルーティング・システムを使って、ユーザによるビュー変更のリクエストを動的に処理する。しかし、ページを右クリックしてView page sourceを選択すると、元のルートファイル(index.html )のコードだけが表示され、現在のUIビューは表示されない。この振る舞いは、特に優れた検索エンジン最適化(SEO)を必要とするWebサイトやアプリを構築する場合、問題となる可能性がある。1(SEO)を必要とするウェブサイトやアプリを構築する場合は特に、この動作が問題になることがある。

さらに、コンテンツをユーザーに表示する前にJavaScriptコードをロードして実行するプロセスでは、ダウンロードするJavaScriptファイルが重い、ネットワークが遅い、ブラウザがコンテンツをペイントするのにかかる時間(First Paint)などの要因により、ユーザーの待ち時間が長くなる可能性がある。その結果、プロセス全体がTime To Interactive(TTI)やFirst Paint(ファースト・ペイント)の遅さにつながる可能性がある。2(TTI)やファースト・コンテンツ・ペイント3(FCP)につながる。これらの要因はすべて、アプリ全体のパフォーマンスとユーザ体験に影響し、多くの場合、修正が困難である 。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

エンジニアが学ぶ会計システムの「知識」と「技術」

エンジニアが学ぶ会計システムの「知識」と「技術」

広川 敬祐, 五島 伸二, 小田 恭彦, 大塚 晃, 川勝 健司
グリーンなソフトウェア開発

グリーンなソフトウェア開発

Anne Currie, Sarah Hsu, Sara Bergman
強力なPython

強力なPython

Aaron Maxwell

Publisher Resources

ISBN: 9798341626102