Performance: Importing from URLs
This affects page load speed and initial script execution time by adding network requests during module loading.
import { serve } from "./vendor/std_http_server.ts"; serve(() => new Response("Hello World"));
import { serve } from "https://deno.land/std@0.177.0/http/server.ts"; serve(() => new Response("Hello World"));
| Pattern | Network Requests | Blocking Time | Cache Usage | Verdict |
|---|---|---|---|---|
| Import from URL | One request per module URL | Blocks script execution until fetched | Depends on HTTP cache; cold start slow | [X] Bad |
| Local or Vendored Import | No network requests at runtime | No blocking from network fetch | Always cached locally | [OK] Good |
import { ... } from "url"; to import from URLs.require, which Deno does not use. import serve from "./server.ts"; imports locally, not from URL. load { serve } from "https://deno.land/std/http/server.ts"; uses invalid keyword load.import { serve } from "https://deno.land/std/http/server.ts";
console.log(typeof serve);serve function is exported from the URL module as a function.serve is a function, typeof serve returns the string "function".import { serve } from "https://deno.land/std/http/server";Pass the test and this pattern moves unknown