From 10e68d7f25d7f17eae76d852058dfb782868454f Mon Sep 17 00:00:00 2001 From: balat Date: Tue, 3 Sep 2024 15:40:38 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ocsigen/?= =?UTF-8?q?tuto@9b1d8289cfb6f7e4fbfce38e19be51a2289e94b3=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/manual/how-to-add-a-javascript-script.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/manual/how-to-add-a-javascript-script.html b/dev/manual/how-to-add-a-javascript-script.html index 2e529745..545597a7 100644 --- a/dev/manual/how-to-add-a-javascript-script.html +++ b/dev/manual/how-to-add-a-javascript-script.html @@ -45,14 +45,14 @@

Warning: Reason support is experimental. We are looking for beta-tester and contributors.

How to add a Javacript script?

If you have client-side programs on your website, you can use Eliom's client-server features, that will compile client side parts to JS using Ocsigen Js_of_ocaml, and include automatically the script in the page. But in some cases you may also want to include yourselves external JS scripts. -

Include the script on the html header

Javascript scripts are included in the header using the js_script function (defined in Error a_api: exception Dune__exe__Api.Error("invalid ocaml id \"Eliom_content.Html.D\"")). +

Include the script on the html header

Javascript scripts are included in the header using the js_script function (defined in Eliom_content.Html.D).

open Eliom_content.Html.D (* for make_uri an js_script *)
 
 js_script
      ~uri:(make_uri (Eliom_service.static_dir ())
               ["hello.js"])
      ()

This function has 2 parameters: the file path and unit. -

The file path is generated using the make_uri function (from Error a_api: exception Dune__exe__Api.Error("invalid ocaml id \"Eliom_content.Html.D\"") module). This function creates the relative URL string using the static directory (which is a service) configured in the configuration file and the given list. +

The file path is generated using the make_uri function (from Eliom_content.Html.D module). This function creates the relative URL string using the static directory (which is a service) configured in the configuration file and the given list.

Insert this piece of code on the list given in parameter to the head function.

Or you can use: Eliom_tools.F.head