Server-Driven Web Apps with Htmx: Any Language, Less Code, Simpler Code

Volkmann, R. Mark

  • 出版商: Pragmatic Bookshelf
  • 出版日期: 2024-09-17
  • 售價: $1,580
  • 貴賓價: 9.5$1,501
  • 語言: 英文
  • 頁數: 186
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 9798888650769
  • ISBN-13: 9798888650769
  • 海外代購書籍(需單獨結帳)

相關主題

商品描述

htmx is a library that adds logic and server interaction to HTML; you get the effect of using a front-end SPA framework without writing front-end code. Use any server-side programming language and framework to build server applications with endpoints that simply return snippets of HTML. Dynamically update portions of the current web page from HTTP responses. Add interactivity with JavaScript and libraries such Alpine and _hyperscript. Make your apps more secure by escaping user-supplied content and specifying a Content Security Policy. Go beyond basic HTTP requests with WebSockets and server-sent events.

The htmx JavaScript library gives you a new way to craft web applications. The htmx approach differs significantly from that of the currently popular single-page application (SPA) frameworks; rather than write a bunch of JavaScript, you simply annotate HTML elements before you send them to the browser. The resulting code is easier to understand and modify, and because it downloads less to the browser and doesn't need JSON creation and parsing, you'll find it performs better, too.

  • Rethink web application design; write code in any language that simply responds to requests with htmx snippets.
  • Dynamically update portions of the current web page directly from the server.
  • Implement common patterns such as lazy loading, input validation, CSS transitions, active search, optimistic updates, pagination, infinite scroll, polling, and click-to-edit.
  • Add interactivity with JavaScript and libraries such as Alpine and _hyperscript.
  • Use the htmx JavaScript API to simplify DOM operations.
  • Make your web apps more secure: escape user-supplied content, use Subresource Integrity hashes, and enforce a Content Security Policy.
  • Go beyond the basic HTTP request/response pattern with WebSockets and server-sent events.
  • Discover a simpler way to implement web applications that emphasizes web fundamentals.

    What You Need:

  • A modern web browser and the ability to build and run a local HTTP server using the server-side language and framework of your choice.
  • The code examples are fully compatible with htmx 2.0.
  • 商品描述(中文翻譯)

    htmx 是一個為 HTML 增加邏輯和伺服器互動的庫;您可以在不撰寫前端代碼的情況下,獲得使用前端 SPA 框架的效果。使用任何伺服器端程式語言和框架來構建伺服器應用程式,這些應用程式的端點僅需返回 HTML 片段。從 HTTP 回應動態更新當前網頁的部分內容。使用 JavaScript 和像 Alpine 及 _hyperscript 等庫來增加互動性。通過轉義用戶提供的內容和指定內容安全政策來提高應用程式的安全性。利用 WebSockets 和伺服器發送事件超越基本的 HTTP 請求。

    htmx JavaScript 庫為您提供了一種全新的方式來構建網頁應用程式。htmx 的方法與當前流行的單頁應用程式 (SPA) 框架有著顯著的不同;您不需要撰寫大量的 JavaScript,而是簡單地在將 HTML 元素發送到瀏覽器之前進行註解。生成的代碼更易於理解和修改,並且因為下載到瀏覽器的內容較少,且不需要 JSON 的創建和解析,您會發現它的性能也更佳。

    - 重新思考網頁應用程式設計;使用任何語言編寫代碼,簡單地用 htmx 片段回應請求。
    - 從伺服器直接動態更新當前網頁的部分內容。
    - 實現常見模式,如延遲加載、輸入驗證、CSS 轉場、主動搜尋、樂觀更新、分頁、無限滾動、輪詢和點擊編輯。
    - 使用 JavaScript 和像 Alpine 及 _hyperscript 等庫來增加互動性。
    - 使用 htmx JavaScript API 簡化 DOM 操作。
    - 提高您的網頁應用程式的安全性:轉義用戶提供的內容,使用子資源完整性哈希,並強制執行內容安全政策。
    - 利用 WebSockets 和伺服器發送事件超越基本的 HTTP 請求/回應模式。

    發現一種更簡單的方式來實現強調網頁基本原則的網頁應用程式。

    您需要的條件:
    - 一個現代的網頁瀏覽器,以及能夠使用您選擇的伺服器端語言和框架構建和運行本地 HTTP 伺服器的能力。
    - 代碼範例與 htmx 2.0 完全兼容。