From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/my/_redirects.txt | 3 + files/my/_wikihistory.json | 141 ++++++ files/my/archive/index.html | 20 + files/my/learn/css/css_layout/flexbox/index.html | 339 ++++++++++++++ files/my/learn/css/css_layout/index.html | 88 ++++ files/my/learn/css/index.html | 67 +++ .../learn/html/forms/html5_input_types/index.html | 276 ++++++++++++ files/my/learn/html/forms/index.html | 83 ++++ .../my/learn/html/forms/your_first_form/index.html | 298 +++++++++++++ files/my/learn/html/index.html | 52 +++ files/my/learn/index.html | 89 ++++ files/my/learn/javascript/index.html | 66 +++ files/my/mozilla/index.html | 12 + files/my/mozilla/localization/index.html | 17 + .../localization/l10n_style_guide/index.html | 485 +++++++++++++++++++++ .../adding_a_new_telemetry_probe/index.html | 184 ++++++++ files/my/mozilla/performance/index.html | 143 ++++++ files/my/web/css/@font-face/index.html | 196 +++++++++ files/my/web/css/css_transitions/index.html | 59 +++ files/my/web/css/index.html | 110 +++++ files/my/web/guide/index.html | 67 +++ .../connection_management_in_http_1.x/index.html | 86 ++++ files/my/web/http/index.html | 90 ++++ files/my/web/index.html | 90 ++++ files/my/web/javascript/index.html | 104 +++++ files/my/web/javascript/reference/index.html | 312 +++++++++++++ .../reference/statements/function_star_/index.html | 252 +++++++++++ .../web/javascript/reference/statements/index.html | 130 ++++++ 28 files changed, 3859 insertions(+) create mode 100644 files/my/_redirects.txt create mode 100644 files/my/_wikihistory.json create mode 100644 files/my/archive/index.html create mode 100644 files/my/learn/css/css_layout/flexbox/index.html create mode 100644 files/my/learn/css/css_layout/index.html create mode 100644 files/my/learn/css/index.html create mode 100644 files/my/learn/html/forms/html5_input_types/index.html create mode 100644 files/my/learn/html/forms/index.html create mode 100644 files/my/learn/html/forms/your_first_form/index.html create mode 100644 files/my/learn/html/index.html create mode 100644 files/my/learn/index.html create mode 100644 files/my/learn/javascript/index.html create mode 100644 files/my/mozilla/index.html create mode 100644 files/my/mozilla/localization/index.html create mode 100644 files/my/mozilla/localization/l10n_style_guide/index.html create mode 100644 files/my/mozilla/performance/adding_a_new_telemetry_probe/index.html create mode 100644 files/my/mozilla/performance/index.html create mode 100644 files/my/web/css/@font-face/index.html create mode 100644 files/my/web/css/css_transitions/index.html create mode 100644 files/my/web/css/index.html create mode 100644 files/my/web/guide/index.html create mode 100644 files/my/web/http/connection_management_in_http_1.x/index.html create mode 100644 files/my/web/http/index.html create mode 100644 files/my/web/index.html create mode 100644 files/my/web/javascript/index.html create mode 100644 files/my/web/javascript/reference/index.html create mode 100644 files/my/web/javascript/reference/statements/function_star_/index.html create mode 100644 files/my/web/javascript/reference/statements/index.html (limited to 'files/my') diff --git a/files/my/_redirects.txt b/files/my/_redirects.txt new file mode 100644 index 0000000000..8254869bb0 --- /dev/null +++ b/files/my/_redirects.txt @@ -0,0 +1,3 @@ +# FROM-URL TO-URL +/my/docs/Learn/CSS/CSS-%E1%80%99%E1%80%AD%E1%80%90%E1%80%BA%E1%80%86%E1%80%80%E1%80%BA /en-US/docs/Learn/CSS/First_steps +/my/docs/Web/Guide/HTML /my/docs/Learn/HTML diff --git a/files/my/_wikihistory.json b/files/my/_wikihistory.json new file mode 100644 index 0000000000..967f0c399a --- /dev/null +++ b/files/my/_wikihistory.json @@ -0,0 +1,141 @@ +{ + "Learn": { + "modified": "2020-07-16T22:43:45.027Z", + "contributors": [ + "SphinxKnight", + "vonabbas", + "Ko.Kyaw.Zin.Htet", + "wuthmone", + "SetKyarWaLar" + ] + }, + "Learn/CSS": { + "modified": "2020-07-16T22:25:35.633Z", + "contributors": [ + "Ko.Kyaw.Zin.Htet", + "josh-wong" + ] + }, + "Learn/CSS/CSS_layout": { + "modified": "2020-08-17T12:09:16.635Z", + "contributors": [ + "chrisdavidmills" + ] + }, + "Learn/CSS/CSS_layout/Flexbox": { + "modified": "2020-08-17T12:09:18.877Z", + "contributors": [ + "sithuyannaing558" + ] + }, + "Learn/HTML": { + "modified": "2020-07-16T22:22:20.967Z", + "contributors": [ + "Ko.Kyaw.Zin.Htet", + "waizinnaing" + ] + }, + "Learn/HTML/Forms": { + "modified": "2020-07-16T22:21:00.247Z", + "contributors": [ + "Jeffrey_Yang" + ] + }, + "Learn/HTML/Forms/HTML5_input_types": { + "modified": "2020-07-16T22:22:06.907Z", + "contributors": [ + "wesleydanbury69" + ] + }, + "Learn/HTML/Forms/Your_first_form": { + "modified": "2020-08-24T11:21:29.703Z", + "contributors": [ + "robertaungzinpyae" + ] + }, + "Learn/JavaScript": { + "modified": "2020-07-16T22:29:42.023Z", + "contributors": [ + "SphinxKnight" + ] + }, + "Mozilla": { + "modified": "2020-12-07T20:30:31.755Z", + "contributors": [ + "jsx" + ] + }, + "Web": { + "modified": "2019-03-23T22:51:40.029Z", + "contributors": [ + "Ko.Kyaw.Zin.Htet", + "Yhaza", + "royhowie" + ] + }, + "Web/CSS": { + "modified": "2019-09-11T03:20:08.570Z", + "contributors": [ + "SphinxKnight" + ] + }, + "Web/CSS/@font-face": { + "modified": "2020-10-15T22:32:44.803Z", + "contributors": [ + "nainglinoo.mm127" + ] + }, + "Web/CSS/CSS_Transitions": { + "modified": "2019-05-23T03:26:30.898Z", + "contributors": [ + "SphinxKnight" + ] + }, + "Web/Guide": { + "modified": "2019-03-23T22:48:31.803Z", + "contributors": [ + "teoli" + ] + }, + "Web/HTTP": { + "modified": "2020-10-13T11:14:22.959Z", + "contributors": [ + "SphinxKnight" + ] + }, + "Web/HTTP/Connection_management_in_HTTP_1.x": { + "modified": "2020-10-14T02:51:32.014Z", + "contributors": [ + "SphinxKnight", + "suran0425" + ] + }, + "Web/JavaScript": { + "modified": "2020-03-12T19:42:07.096Z", + "contributors": [ + "csdal", + "SphinxKnight", + "SetKyarWaLar", + "SuThaw", + "Markus Prokott" + ] + }, + "Web/JavaScript/Reference": { + "modified": "2020-07-22T11:39:39.861Z", + "contributors": [ + "fscholz" + ] + }, + "Web/JavaScript/Reference/Statements": { + "modified": "2020-10-15T22:32:02.841Z", + "contributors": [ + "wbamberg" + ] + }, + "Web/JavaScript/Reference/Statements/function*": { + "modified": "2020-10-15T22:32:02.196Z", + "contributors": [ + "wilsunluk" + ] + } +} \ No newline at end of file diff --git a/files/my/archive/index.html b/files/my/archive/index.html new file mode 100644 index 0000000000..c67d0390d8 --- /dev/null +++ b/files/my/archive/index.html @@ -0,0 +1,20 @@ +--- +title: Archive of obsolete content +slug: Archive +translation_of: Archive +--- +

(my translation)

+ +

Here at MDN, we try to avoid outright deleting content that might be useful to people targeting legacy platforms, operating systems, and browsers. Perhaps your target audience is people that are using older hardware, for example, and can't upgrade to the latest and greatest browsers. Or for "reasons," your company is required to use very old software and you need to build Web content that runs on that software. Or perhaps you're just curious about the history of an obsolete feature or API, and how it worked.

+ +

There are many reasons older documentation can be useful. So, we've established this area into which we can archive older documentation. Material in this Archived content zone should not be used for building new Web sites or apps for modern browsers. It's here for historical reference only.

+ +
+

Note to writers: We need to try to keep the subpages here organized instead of all dumped into one large folder. Try to create subtrees for categories of material. Also, only move pages here that are extremely obsolete. If anyone might realistically need the information in a living product, it may not be appropriate to move it here. In general, it may be best to discuss it in the MDN Web Docs chat room before moving content here.

+
+ +

{{SubpagesWithSummaries}}

+ + + +

{{ListSubpages("/en-US/docs/Archive", 2, 0, 1)}}

diff --git a/files/my/learn/css/css_layout/flexbox/index.html b/files/my/learn/css/css_layout/flexbox/index.html new file mode 100644 index 0000000000..03bc087105 --- /dev/null +++ b/files/my/learn/css/css_layout/flexbox/index.html @@ -0,0 +1,339 @@ +--- +title: Flexbox +slug: Learn/CSS/CSS_layout/Flexbox +translation_of: Learn/CSS/CSS_layout/Flexbox +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("LearnSS_layout/Normal_Flow", "Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout")}}
+ +

Flexbox is a one-dimensional layout method for laying out items in rows or columns. Items flex to fill additional space and shrink to fit into smaller spaces. This article explains all the fundamentals.

+ + + + + + + + + + + + +
Prerequisites:HTML basics (study Introduction to HTML), and an idea of how CSS works (study Introduction to CSS.)
Objective:To learn how to use the Flexbox layout system to create web layouts.
+ +

Why Flexbox?

+ +

For a long time, the only reliable cross browser-compatible tools available for creating CSS layouts were things like floats and positioning. These are fine and they work, but in some ways they are also rather limiting and frustrating.

+ +

The following simple layout requirements are either difficult or impossible to achieve with such tools, in any kind of convenient, flexible way:

+ + + +

As you'll see in subsequent sections, flexbox makes a lot of layout tasks much easier. Let's dig in!

+ +

Introducing a simple example

+ +

In this article we are going to get you to work through a series of exercises to help you understand how flexbox works. To get started, you should make a local copy of the first starter file — flexbox0.html from our github repo — load it in a modern browser (like Firefox or Chrome), and have a look at the code in your code editor. You can see it live here also.

+ +

You'll see that we have a {{htmlelement("header")}} element with a top level heading inside it, and a {{htmlelement("section")}} element containing three {{htmlelement("article")}}s. We are going to use these to create a fairly standard three column layout.

+ +

+ +

Specifying what elements to lay out as flexible boxes

+ +

To start with, we need to select which elements are to be laid out as flexible boxes. To do this, we set a special value of {{cssxref("display")}} on the parent element of the elements you want to affect. In this case we want to lay out the {{htmlelement("article")}} elements, so we set this on the {{htmlelement("section")}}:

+ +
section {
+  display: flex;
+}
+ +

This causes the <section> element to become a flex container, and its children to become flex items. The result of this should be something like so:

+ +

+ +

So, this single declaration gives us everything we need — incredible, right? We have our multiple column layout with equal sized columns, and the columns are all the same height. This is because the default values given to flex items (the children of the flex container) are set up to solve common problems such as this.

+ +

To be clear, let's reiterate what is happening here. The element we've given a   {{cssxref("display")}} value of flex to is acting like a block-level element in terms of how it interacts with the rest of the page, but its children are being laid out as flex items — the next section will explain in more detail what this means. Note also that you can use a display value of inline-flex if you wish to lay out an element's children as flex items, but have that element behave like an inline element.

+ +

The flex model

+ +

When elements are laid out as flex items, they are laid out along two axes:

+ +

flex_terms.png

+ + + +

Bear this terminology in mind as you go through subsequent sections. You can always refer back to it if you get confused about any of the terms being used.

+ +

Columns or rows?

+ +

Flexbox provides a property called {{cssxref("flex-direction")}} that specifies what direction the main axis runs in (what direction the flexbox children are laid out in) — by default this is set to row, which causes them to be laid out in a row in the direction your browser's default language works in (left to right, in the case of an English browser).

+ +

Try adding the following declaration to your {{htmlelement("section")}} rule:

+ +
flex-direction: column;
+ +

You'll see that this puts the items back in a column layout, much like they were before we added any CSS. Before you move on, delete this declaration from your example.

+ +
+

Note: You can also lay out flex items in a reverse direction using the row-reverse and column-reverse values. Experiment with these values too!

+
+ +

Wrapping

+ +

One issue that arises when you have a fixed amount of width or height in your layout is that eventually your flexbox children will overflow their container, breaking the layout. Have a look at our flexbox-wrap0.html example, and try viewing it live (take a local copy of this file now if you want to follow along with this example):

+ +

+ +

Here we see that the children are indeed breaking out of their container. One way in which you can fix this is to add the following declaration to your {{htmlelement("section")}} rule:

+ +
flex-wrap: wrap;
+ +

Also, add the following declaration to your {{htmlelement("article")}} rule:

+ +
flex: 200px;
+ +

Try this now; you'll see that the layout looks much better with this included:

+ +

We now have multiple rows — as many flexbox children are fitted onto each row as makes sense, and any overflow is moved down to the next line. The flex: 200px declaration set on the articles means that each will be at least 200px wide; we'll discuss this property in more detail later on. You might also notice that the last few children on the last row are each made wider so that the entire row is still filled.

+ +

But there's more we can do here. First of all, try changing your {{cssxref("flex-direction")}} property value to row-reverse — now you'll see that you still have your multiple row layout, but it starts from the opposite corner of the browser window and flows in reverse.

+ +

flex-flow shorthand

+ +

At this point it is worth noting that a shorthand exists for {{cssxref("flex-direction")}} and {{cssxref("flex-wrap")}} — {{cssxref("flex-flow")}}. So for example, you can replace

+ +
flex-direction: row;
+flex-wrap: wrap;
+ +

with

+ +
flex-flow: row wrap;
+ +

Flexible sizing of flex items

+ +

Let's now return to our first example, and look at how we can control what proportion of space flex items take up compared to the other flex items. Fire up your local copy of flexbox0.html, or take a copy of flexbox1.html as a new starting point (see it live).

+ +

First, add the following rule to the bottom of your CSS:

+ +
article {
+  flex: 1;
+}
+ +

This is a unitless proportion value that dictates how much of the available space along the main axis each flex item will take up compared to other flex items. In this case, we are giving each {{htmlelement("article")}} element the same value (a value of 1), which means they will all take up an equal amount of the spare space left after things like padding and margin have been set. It is relative to other flex items, meaning that giving each flex item a value of 400000 would have exactly the same effect.

+ +

Now add the following rule below the previous one:

+ +
article:nth-of-type(3) {
+  flex: 2;
+}
+ +

Now when you refresh, you'll see that the third {{htmlelement("article")}} takes up twice as much of the available width as the other two — there are now four proportion units available in total (since 1 + 1 + 2 = 4). The first two flex items have one unit each so they take 1/4 of the available space each. The third one has two units, so it takes up 2/4 of the available space (or one-half).

+ +

You can also specify a minimum size value inside the flex value. Try updating your existing article rules like so:

+ +
article {
+  flex: 1 200px;
+}
+
+article:nth-of-type(3) {
+  flex: 2 200px;
+}
+ +

This basically states "Each flex item will first be given 200px of the available space. After that, the rest of the available space will be shared out according to the proportion units." Try refreshing and you'll see a difference in how the space is shared out.

+ +

+ +

The real value of flexbox can be seen in its flexibility/responsiveness — if you resize the browser window, or add another {{htmlelement("article")}} element, the layout continues to work just fine.

+ +

flex: shorthand versus longhand

+ +

{{cssxref("flex")}} is a shorthand property that can specify up to three different values:

+ + + +

We'd advise against using the longhand flex properties unless you really have to (for example, to override something previously set). They lead to a lot of extra code being written, and they can be somewhat confusing.

+ +

Horizontal and vertical alignment

+ +

You can also use flexbox features to align flex items along the main or cross axis. Let's explore this by looking at a new example — flex-align0.html (see it live also) — which we are going to turn into a neat, flexible button/toolbar. At the moment you'll see a horizontal menu bar, with some buttons jammed into the top left hand corner.

+ +

+ +

First, take a local copy of this example.

+ +

Now, add the following to the bottom of the example's CSS:

+ +
div {
+  display: flex;
+  align-items: center;
+  justify-content: space-around;
+}
+ +

+ +

Refresh the page and you'll see that the buttons are now nicely centered, horizontally and vertically. We've done this via two new properties.

+ +

{{cssxref("align-items")}} controls where the flex items sit on the cross axis.

+ + + +

You can override the {{cssxref("align-items")}} behavior for individual flex items by applying the {{cssxref("align-self")}} property to them. For example, try adding the following to your CSS:

+ +
button:first-child {
+  align-self: flex-end;
+}
+ +

+ +

Have a look at what effect this has, and remove it again when you've finished.

+ +

{{cssxref("justify-content")}} controls where the flex items sit on the main axis.

+ + + +

We'd like to encourage you to play with these values to see how they work before you continue.

+ +

Ordering flex items

+ +

Flexbox also has a feature for changing the layout order of flex items, without affecting the source order. This is another thing that is impossible to do with traditional layout methods.

+ +

The code for this is simple: try adding the following CSS to your button bar example code:

+ +
button:first-child {
+  order: 1;
+}
+ +

Refresh, and you'll now see that the "Smile" button has moved to the end of the main axis. Let's talk about how this works in a bit more detail:

+ + + +

You can set negative order values to make items appear earlier than items with 0 set. For example, you could make the "Blush" button appear at the start of the main axis using the following rule:

+ +
button:last-child {
+  order: -1;
+}
+ +

Nested flex boxes

+ +

It is possible to create some pretty complex layouts with flexbox. It is perfectly ok to set a flex item to also be a flex container, so that its children are also laid out like flexible boxes. Have a look at complex-flexbox.html (see it live also).

+ +

+ +

The HTML for this is fairly simple. We've got a {{htmlelement("section")}} element containing three {{htmlelement("article")}}s. The third {{htmlelement("article")}} contains three {{htmlelement("div")}}s. :

+ +
section - article
+          article
+          article - div - button
+                    div   button
+                    div   button
+                          button
+                          button
+ +

Let's look at the code we've used for the layout.

+ +

First of all, we set the children of the {{htmlelement("section")}} to be laid out as flexible boxes.

+ +
section {
+  display: flex;
+}
+ +

Next, we set some flex values on the {{htmlelement("article")}}s themselves. Take special note of the 2nd rule here — we are setting the third {{htmlelement("article")}} to have its children laid out like flex items too, but this time we are laying them out like a column.

+ +
article {
+  flex: 1 200px;
+}
+
+article:nth-of-type(3) {
+  flex: 3 200px;
+  display: flex;
+  flex-flow: column;
+}
+
+ +

Next, we select the first {{htmlelement("div")}}. We first use flex:1 100px; to effectively give it a minimum height of 100px, then we set its children (the {{htmlelement("button")}} elements) to also be laid out like flex items. Here we lay them out in a wrapping row, and align them in the center of the available space like we did in the individual button example we saw earlier.

+ +
article:nth-of-type(3) div:first-child {
+  flex:1 100px;
+  display: flex;
+  flex-flow: row wrap;
+  align-items: center;
+  justify-content: space-around;
+}
+ +

Finally, we set some sizing on the button, but more interestingly we give it a flex value of 1 auto. This has a very interesting effect, which you'll see if you try resizing your browser window width. The buttons will take up as much space as they can and sit as many on the same line as they can, but when they can no longer fit comfortably on the same line, they'll drop down to create new lines.

+ +
button {
+  flex: 1 auto;
+  margin: 5px;
+  font-size: 18px;
+  line-height: 1.5;
+}
+ +

Cross browser compatibility

+ +

Flexbox support is available in most new browsers — Firefox, Chrome, Opera, Microsoft Edge and IE 11, newer versions of Android/iOS, etc. However you should be aware that there are still older browsers in use that don't support Flexbox (or do, but support a really old, out-of-date version of it.)

+ +

While you are just learning and experimenting, this doesn't matter too much; however if you are considering using flexbox in a real website you need to do testing and make sure that your user experience is still acceptable in as many browsers as possible.

+ +

Flexbox is a bit trickier than some CSS features. For example, if a browser is missing a CSS drop shadow, then the site will likely still be usable. Not supporting flexbox features however will probably break a layout completely, making it unusable.

+ +

We discuss strategies for overcoming cross browser support issues in our Cross browser testing module.

+ +

Test your skills!

+ +

We have covered a lot in this article, but can you remember the most important information? You can find some further tests to verify that you've retained this information before you move on — see Test your skills: Flexbox.

+ +

Summary

+ +

That concludes our tour of the basics of flexbox. We hope you had fun, and will have a good play around with it as you travel forward with your learning. Next we'll have a look at another important aspect of CSS layouts — CSS Grids.

+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Normal_Flow", "Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout")}}
+ +
+

In this module

+ + +
diff --git a/files/my/learn/css/css_layout/index.html b/files/my/learn/css/css_layout/index.html new file mode 100644 index 0000000000..4351951f84 --- /dev/null +++ b/files/my/learn/css/css_layout/index.html @@ -0,0 +1,88 @@ +--- +title: CSS layout +slug: Learn/CSS/CSS_layout +tags: + - Beginner + - CSS + - Floating + - Grids + - Guide + - Landing + - Layout + - Learn + - Module + - Multiple column + - NeedsTranslation + - Positioning + - TopicStub + - alignment + - flexbox + - float + - table +translation_of: Learn/CSS/CSS_layout +--- +
{{LearnSidebar}}
+ +

At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about.

+ +
+

Looking to become a front-end web developer?

+ +

We have put together a course that includes all the essential information you need to work towards your goal.

+ +

Get started

+
+ +

Prerequisites

+ +

Before starting this module, you should already:

+ +
    +
  1. Have basic familiarity with HTML, as discussed in the Introduction to HTML module.
  2. +
  3. Be comfortable with CSS fundamentals, as discussed in Introduction to CSS.
  4. +
  5. Understand how to style boxes.
  6. +
+ +
+

Note: If you are working on a computer/tablet/other device where you don't have the ability to create your own files, you could try out (most of) the code examples in an online coding program such as JSBin or Glitch.

+
+ +

Guides

+ +

These articles will provide instruction on the fundamental layout tools and techniques available in CSS. At the end of the lessons is an assessment to help you check your understanding of layout methods, by laying out a webpage.

+ +
+
Introduction to CSS layout
+
This article will recap some of the CSS layout features we've already touched upon in previous modules — such as different {{cssxref("display")}} values — and introduce some of the concepts we'll be covering throughout this module.
+
Normal flow
+
Elements on webpages lay themselves out according to normal flow - until we do something to change that. This article explains the basics of normal flow as a grounding for learning how to change it.
+
Flexbox
+
Flexbox is a one-dimensional layout method for laying out items in rows or columns. Items flex to fill additional space and shrink to fit into smaller spaces. This article explains all the fundamentals. After studying this guide you can test your flexbox skills to check your understanding before moving on.
+
Grids
+
CSS Grid Layout is a two-dimensional layout system for the web. It lets you lay content out in rows and columns, and has many features that make building complex layouts straightforward. This article will give you all you need to know to get started with page layout, then test your grid skills before moving on.
+
Floats
+
Originally for floating images inside blocks of text, the {{cssxref("float")}} property became one of the most commonly used tools for creating multiple column layouts on webpages. With the advent of Flexbox and Grid it has now returned to its original purpose, as this article explains.
+
Positioning
+
Positioning allows you to take elements out of the normal document layout flow, and make them behave differently, for example sitting on top of one another, or always remaining in the same place inside the browser viewport. This article explains the different {{cssxref("position")}} values, and how to use them.
+
Multiple-column layout
+
The multiple-column layout specification gives you a method of laying content out in columns, as you might see in a newspaper. This article explains how to use this feature.
+
Responsive design
+
As more diverse screen sizes have appeared on web-enabled devices, the concept of responsive web design (RWD) has appeared: a set of practices that allows web pages to alter their layout and appearance to suit different screen widths, resolutions, etc. It is an idea that changed the way we design for a multi-device web, and in this article we'll help you understand the main techniques you need to know to master it.
+
Beginner's guide to media queries
+
The CSS Media Query gives you a way to apply CSS only when the browser and device environment matches a rule that you specify, for example "viewport is wider than 480 pixels". Media queries are a key part of responsive web design, as they allow you to create different layouts depending on the size of the viewport, but they can also be used to detect other things about the environment your site is running on, for example whether the user is using a touchscreen rather than a mouse. In this lesson you will first learn about the syntax used in media queries, and then move on to use them in a worked example showing how a simple design might be made responsive.
+
Legacy layout methods
+
Grid systems are a very common feature used in CSS layouts, and before CSS Grid Layout they tended to be implemented using floats or other layout features. You imagine your layout as a set number of columns (e.g. 4, 6, or 12), and then fit your content columns inside these imaginary columns. In this article we'll explore how these older methods work, in order that you understand how they were used if you work on an older project.
+
Supporting older browsers
+
+

In this module we recommend using Flexbox and Grid as the main layout methods for your designs. However there will be visitors to your site who use older browsers, or browsers which do not support the methods you have used. This will always be the case on the web — as new features are developed, different browsers will prioritise different things. This article explains how to use modern web techniques without locking out users of older technology.

+
+
Assessment: Fundamental layout comprehension
+
An assessment to test your knowledge of different layout methods by laying out a webpage.
+
+ +

See also

+ +
+
Practical positioning examples
+
This article shows how to build some real world examples to illustrate what kinds of things you can do with positioning.
+
diff --git a/files/my/learn/css/index.html b/files/my/learn/css/index.html new file mode 100644 index 0000000000..781ea7fb45 --- /dev/null +++ b/files/my/learn/css/index.html @@ -0,0 +1,67 @@ +--- +title: CSS နင့် HTML အား အသွင်ပောင်းခင်း +slug: Learn/CSS +tags: + - Beginner + - CSS + - CodingScripting + - Debugging + - Landing + - NeedsContent + - NeedsTranslation + - Style + - Topic + - TopicStub + - length + - specificity +translation_of: Learn/CSS +--- +
{{LearnSidebar}}
+ +

Cascading Stylesheets — or {{glossary("CSS")}} — is the first technology you should start learning after {{glossary("HTML")}}. While HTML is used to define the structure and semantics of your content, CSS is used to style it and lay it out. For example, you can use CSS to alter the font, color, size, and spacing of your content, split it into multiple columns, or add animations and other decorative features.

+ +

သင်ယူမုဆိုင်ရာ လမ်းေကာင်း

+ +

You should learn the basics of HTML before attempting any CSS. We recommend that you work through our Introduction to HTML module first. In that module, you will learn about:

+ + + +

Once you understand the fundamentals of HTML, we recommend that you learn HTML and CSS at the same time, moving back and forth between the two topics. This is because HTML is far more interesting and much more fun to learn when you apply CSS, and you can't really learn CSS without knowing HTML.

+ +

Before starting this topic, you should also be familiar with using computers and using the web passively (i.e., just looking at it, consuming the content). You should have a basic work environment set up as detailed in Installing basic software and understand how to create and manage files, as detailed in Dealing with files — both of which are parts of our Getting started with the web complete beginner's module.

+ +

It is recommended that you work through Getting started with the web before proceeding with this topic. However, doing so isn't absolutely necessary as much of what is covered in the CSS basics article is also covered in our Introduction to CSS module, albeit in a lot more detail.

+ +

သင်ရိုး

+ +

This topic contains the following modules, in a suggested order for working through them. You should definitely start with the first one.

+ +
+
Introduction to CSS
+
This module gets you started with the basics of how CSS works, including using selectors and properties; writing CSS rules; applying CSS to HTML; specifying length, color, and other units in CSS; controlling cascade and inheritance; understanding box model basics; and debugging CSS.
+
Styling text
+
Here, we look at text-styling fundamentals, including setting font, boldness, and italics; line and letter spacing; and drop shadows and other text features. We round off the module by looking at applying custom fonts to your page and styling lists and links.
+
Styling boxes
+
Next up, we look at styling boxes, one of the fundamental steps towards laying out a web page. In this module, we recap the box model, then look at controlling box layouts by setting padding, borders and margins, setting custom background colors, images, and fancy features such as drop shadows and filters on boxes.
+
CSS layout
+
At this point, we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now, it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about.
+
Responsive design (TBD)
+
With so many different types of devices able to browse the web these days, responsive web design (RWD) has become a core web development skill. This module will cover the basic principles and tools of RWD; explain how to apply different CSS to a document depending on device features like screen width, orientation, and resolution; and explore the technologies available for serving different videos and images depending on such features.
+
+ +

CSS ဆိုင်ရာ ပသနာများဖေရင်းခင်း

+ +

Use CSS to solve common problems provides links to sections of content explaining how to use CSS to solve very common problems when creating a web page.

+ +

From the beginning, you'll primarily apply colors to HTML elements and their backgrounds; change the size, shape, and position of elements; and add and define borders on elements. But there's not much you can't do once you have a solid understanding of even the basics of CSS. One of the best things about learning CSS is that once you know the fundamentals, usually you have a pretty good feel for what can and can't be done, even if you don't actually know how to do it yet!

+ +

ပိုမိုလေ့လာရန်

+ +
+
CSS on MDN
+
The main entry point for CSS documentation on MDN, where you'll find detailed reference documentation for all features of the CSS language. Want to know all the values a property can take? This is a good place to go.
+
diff --git a/files/my/learn/html/forms/html5_input_types/index.html b/files/my/learn/html/forms/html5_input_types/index.html new file mode 100644 index 0000000000..74b3202f26 --- /dev/null +++ b/files/my/learn/html/forms/html5_input_types/index.html @@ -0,0 +1,276 @@ +--- +title: The HTML5 input types +slug: Learn/HTML/Forms/HTML5_input_types +translation_of: Learn/Forms/HTML5_input_types +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Forms/Basic_native_form_controls", "Learn/Forms/Other_form_controls", "Learn/Forms")}}
+ +

In the previous article we looked at the {{htmlelement("input")}} element, covering the original values of the type attribute available since the early days of HTML. Now we'll look at the functionality of newer form controls in detail, including some new input types, which were added in HTML5 to allow collection of specific types of data.

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, and a basic understanding of HTML.
Objective:To understand the newer input type values available to create native form controls, and how to implement them using HTML.
+ +
+

Note: Most of the features discussed in this article have wide support across browsers. We'll note any exceptions. If you want more detail on browser support, you should consult our HTML forms element reference, and in particular our extensive <input> types reference.

+
+ +

Because HTML form control appearance may be quite different from a designer's specifications, web developers sometimes build their own custom form controls. We cover this in an advanced tutorial — How to build custom form widgets.

+ +

E-mail address field

+ +

This type of field is set using the value email for the {{htmlattrxref("type","input")}} attribute:

+ +
<input type="email" id="email" name="email">
+ +

When this {{htmlattrxref("type","input")}} is used, the user is required to type a valid email address into the field. Any other content causes the browser to display an error when the form is submitted. You can see this in action in the below screenshot.

+ +

An invalid email input showing the message "Please enter an email address."

+ +

You can also use the multiple attribute in combination with the email input type to allow several email addresses to be entered in the same input (separated by commas):

+ +
<input type="email" id="email" name="email" multiple>
+ +

On some devices — notably, touch devices with dynamic keyboards like smart phones — a different virtual keypad might be presented that is more suitable for entering email addresses, including the @ key. See the Firefox for Android keyboard screenshot below for an example:

+ +

firefox for android email keyboard, with ampersand displayed by default.

+ +
+

Note: You can find examples of the basic text input types at basic input examples (see the source code also).

+
+ +

This is another good reason for using these newer input types — improving the user experience for users of these devices.

+ +

Client-side validation

+ +

As you can see above, email, along with other newer input types, provides built-in client-side error validation — performed by the browser before the data gets sent to the server. It is a helpful aid to guide users to fill out a form accurately, and it can save time — it is useful to know that your data is not correct immediately, rather than having to wait for a round trip to the server.

+ +

But it should not be considered an exhaustive security measure! Your apps should always perform security checks on any form-submitted data on the server-side as well as the client-side, because client-side validation is too easy to turn off, so malicious users can still easily send bad data through to your server. Read Website security for an idea of what could happen; implementing server-side validation is somewhat beyond the scope of this module, but you should bear it in mind.

+ +

Note that a@b is a valid email address according to the default provided constraints. This is because the email input type allows intranet email addresses by default. To implement different validation behavior, you can use the pattern attribute, and you can also custom the error messages; we'll talk how to use these features in the Client-side form validation article later on.

+ +
+

Note: If the data entered is not an email address, the {{cssxref(':invalid')}} pseudo-class will match, and the {{domxref('validityState.typeMismatch')}} property will return true.

+
+ +

Search field

+ +

Search fields are intended to be used to create search boxes on pages and apps. This type of field is set by using the value search for the {{htmlattrxref("type","input")}} attribute:

+ +
<input type="search" id="search" name="search">
+ +

The main difference between a text field and a search field is how the browser styles its appearance.  Often, search fields are rendered with rounded corners; they also sometimes display an "Ⓧ", which clears the field of any value when clicked). Additionally, on devices with dynamic keyboards, the keyboard's enter key may read "search", or display a magnifying glass icon.

+ +

The below screenshots show a non-empty search field in Firefox 71, Safari 13, and Chrome 79 on macOS, and Edge 18 and Chrome 79 on Windows 10. Note the clear icon only appears if the field has a value, and, apart from Safari, it is only displayed when the field is focused.

+ +

Screenshots of search fields on several platforms.

+ +

Another feature worth noting is that the values of a search field can be automatically saved and re-used to offer auto-completion across multiple pages of the same website. This tends to happen automatically in most modern browsers.

+ +

Phone number field

+ +

A special field for filling in phone numbers can be created using tel as the value of the {{htmlattrxref("type","input")}} attribute:

+ +
<input type="tel" id="tel" name="tel">
+ +

When accessed via a touch device with a dynamic keyboard, most devices will display a numeric keypad when type="tel" is encountered, meaning this type is useful whenever a numeric keypad is useful, and doesn't just have to be used for telephone numbers.

+ +

The following Firefox for Android keyboard screenshot provides an example:

+ +

firefox for android email keyboard, with ampersand displayed by default.

+ +

Due to the wide variety of phone number formats around the world, this type of field does not enforce any constraints on the value entered by a user. (This means it may include letters, etc.).

+ +

As we mentioned earlier, The pattern attribute can be used to enforce constraints, which you'll learn about in Client-side form validation.

+ +

URL field

+ +

A special type of field for entering URLs can be created using the value url for the {{htmlattrxref("type","input")}} attribute:

+ +
<input type="url" id="url" name="url">
+ +

It adds special validation constraints to the field. The browser will report an error if no protocol (such as http:) is entered, or if the URL is otherwise malformed. On devices with dynamic keyboards, the default keyboard will often display some or all of the colon, period, and forward slash as default keys.

+ +

See below for an example (taken on Fireox for Android):

+ +

firefox for android email keyboard, with ampersand displayed by default.

+ +
Note: Just because the URL is well-formed doesn't necessarily mean that it refers to a location that actually exists!
+ +

Numeric field

+ +

Controls for entering numbers can be created with an {{HTMLElement("input")}} {{htmlattrxref("type","input")}} of number. This control looks like a text field but allows only floating-point numbers, and usually provides buttons in the form of a spinner to increase and decrease the value of the control. On devices with dynamic keyboards, the numeric keyboard is generally displayed.

+ +

The following screenshot (from Firefox for Android) provides an example:

+ +

firefox for android email keyboard, with ampersand displayed by default.

+ +

With the number input type, you can constrain the minimum and maximum values allowed by setting the {{htmlattrxref("min","input")}} and {{htmlattrxref("max","input")}} attributes.

+ +

You can also use the step attribute to set the increment increase and decrease caused by pressing the spinner buttons. By default, the number input type only validates if the number is an integer. To allow float numbers, specify step="any". If omitted, the step value defaults to 1, meaning only whole numbers are valid.

+ +

Let's look at some examples. The first one below creates a number control whose value is restricted to any value between 1 and 10, and whose increase and decrease buttons change its value by 2.

+ +
<input type="number" name="age" id="age" min="1" max="10" step="2">
+ +

The second one creates a number control whose value is restricted to any value between 0 and 1 inclusive, and whose increase and decrease buttons change its value by 0.01.

+ +
<input type="number" name="change" id="pennies" min="0" max="1" step="0.01">
+ +

The number input type makes sense when the range of valid values is limited, for example a person's age or height. If the range is too large for incremental increases to make sense (such as USA ZIP codes, which range from 00001 to 99999), the tel type might be a better option; it provides the numeric keypad while forgoing the number's spinner UI feature.

+ +
+

Note: number inputs are not supported in versions of Internet Explorer below 10.

+
+ +

Slider controls

+ +

Another way to pick a number is to use a slider. You see these quite often on sites like housebuying sites where you want to set a maximum property price to filter by. Let's look at a live example to illustrate this:

+ +

{{EmbedGHLiveSample("learning-area/html/forms/range-example/index.html", '100%', 200)}}

+ +

Usage-wise, sliders are less accurate than text fields. Therefore, they are used to pick a number whose precise value is not necessarily important.

+ +

A slider is created using the {{HTMLElement("input")}} with its {{htmlattrxref("type","input")}} attribute set to the value range. The slider-thumb can be moved via mouse or touch, or with the arrows of the keypad.

+ +

It's important to properly configure your slider. To that end, it's highly recommended that you set the min, max, and step attributes which set the minimum, maximum and increment values, respectively.

+ +

Let's look at the code behind the above example, so you can see how its done. First of all, the basic HTML:

+ +
<label for="price">Choose a maximum house price: </label>
+<input type="range" name="price" id="price" min="50000" max="500000" step="100" value="250000">
+<output class="price-output" for="price"></output>
+ +

This example creates a slider whose value may range between 50000 and 500000, which increments/decrements by 100 at a time. We've given it default value of 250000, using the value attribute.

+ +

One problem with sliders is that they don't offer any kind of visual feedback as to what the current value is. This is why we've included an {{htmlelement("output")}} element — to contain the current value (we'll also look at this element in the next article). You could display an input value or the output of a calculation inside any element, but <output> is special — like <label>, it can take a for attribute that allows you to associate it with the element or elements that the output value came from.

+ +

To actually display the current value, and update it as it changed, you must use JavaScript, but this is relatively easy to do:

+ +
const price = document.querySelector('#price')
+const output = document.querySelector('.price-output')
+
+output.textContent = price.value
+
+price.addEventListener('input', function() {
+  output.textContent = price.value
+});
+ +

Here we store references to the range input and the output in two variables. Then we immediately set the output's textContent to the current value of the input. Finally, an event listener is set to ensure that whenever the range slider is moved, the output's textContent is updated to the new value.

+ +
+

Note: range inputs are not supported in versions of Internet Explorer below 10.

+
+ +

Date and time pickers

+ +

Gathering date and time values has traditionally been a nightmare for web developers. For good user experience, it is important to provide a calendar selection UI, enabling users to select dates without necessating context switching to a native calendar application or potentially entering them in differing formats that are hard to parse. The last minute of the previous millenium can be expressed in the following different ways, for example: 1999/12/31, 23:59 or 12/31/99T11:59PM.

+ +

HTML date controls are available to handle this specific kind of data, providing calendar widgets and making the data uniform.

+ +

A date and time control is created using the {{HTMLElement("input")}} element and an appropriate value for the {{htmlattrxref("type","input")}} attribute, depending on whether you wish to collect dates, times, or both. Here's a live example that falls back to {{htmlelement("select")}} elements in non-supporting browsers:

+ +

{{EmbedGHLiveSample("learning-area/html/forms/datetime-local-picker-fallback/index.html", '100%', 200)}}

+ +

Let's look at the different available types in brief. Note that the usage of these types is quite complex, especially considering browser support (see below); to find out the full details, follow the links below to the reference pages for each type, including detailed examples.

+ +

datetime-local

+ +

<input type="datetime-local"> creates a widget to display and pick a date with time with no specific time zone information.

+ +
<input type="datetime-local" name="datetime" id="datetime">
+ +

month

+ +

<input type="month"> creates a widget to display and pick a month with a year.

+ +
<input type="month" name="month" id="month">
+ +

time

+ +

<input type="time"> creates a widget to display and pick a time value. While time may display in 12-hour format, the value returned is in 24-hour format.

+ +
<input type="time" name="time" id="time">
+ +

week

+ +

<input type="week"> creates a widget to display and pick a week number and its year.

+ +

Weeks start on Monday and run to Sunday. Additionally, the first week 1 of each year contains the first Thursday of that year—which may not include the first day of the year, or may include the last few days of the previous year.

+ +
<input type="week" name="week" id="week">
+ +

Constraining date/time values

+ +

All date and time controls can be constrained using the min and max attributes, with further constraining possible via the step attribute (whose value is given in seconds).

+ +
<label for="myDate">When are you available this summer?</label>
+<input type="date" name="myDate" min="2013-06-01" max="2013-08-31" step="3600" id="myDate">
+ +

Browser support for date/time inputs

+ +

You should be warned that the date and time widgets don't have the best browser support. At the moment, Chrome, Edge, and Opera support them well, but there is no support in Internet Explorer, Safari has some mobile support (but no desktop support), and Firefox supports time and date only.

+ +

The reference pages linked to above provide suggestions on how to program fallbacks for non-supporting browsers; another option is to consider using a JavaScript library to provide a date picker. Most modern frameworks have good components available to provide this functionality, and there are standalone libraries available to (see Top date picker javascript plugins and libraries for some suggestions).

+ +

Color picker control

+ +

Colors are always a bit difficult to handle. There are many ways to express them: RGB values (decimal or hexadecimal), HSL values, keywords, etc.

+ +

A color control can be created using the {{HTMLElement("input")}} element with its {{htmlattrxref("type","input")}} attribute set to the value color:

+ +
<input type="color" name="color" id="color">
+ +

When supported, clicking a color control will tend to display the operating system's default color picking functionality for you to actually make your choice with. The following screenshot taken on Firefox for macOS provides an example:

+ +

firefox for android email keyboard, with ampersand displayed by default.

+ +

And here is a live example for you to try out:

+ +

{{EmbedGHLiveSample("learning-area/html/forms/color-example/index.html", '100%', 200)}}

+ +

The value returned is always a lowercase 6-value hexidecimal color.

+ +
+

Note: color inputs are not supported in Internet Explorer.

+
+ +

Summary

+ +

That brings us to the end of our tour of the HTML5 form input types. There are a few other control types that cannot be easily grouped together due to their very specific behaviors, but which are still essential to know about. We cover those in the next article.

+ +

{{PreviousMenuNext("Learn/Forms/Basic_native_form_controls", "Learn/Forms/Other_form_controls", "Learn/Forms")}}

+ +

In this module

+ + + +

Advanced Topics

+ + diff --git a/files/my/learn/html/forms/index.html b/files/my/learn/html/forms/index.html new file mode 100644 index 0000000000..215164d6a6 --- /dev/null +++ b/files/my/learn/html/forms/index.html @@ -0,0 +1,83 @@ +--- +title: HTML forms +slug: Learn/HTML/Forms +tags: + - Beginner + - Featured + - Forms + - Guide + - HTML + - Landing + - Learn + - NeedsTranslation + - TopicStub + - Web +translation_of: Learn/Forms +--- +
{{LearnSidebar}}
+ +

This module provides a series of articles that will help you master HTML forms. HTML forms are a very powerful tool for interacting with users; however, for historical and technical reasons, it's not always obvious how to use them to their full potential. In this guide, we'll cover all aspects of HTML forms, from structure to styling, from data handling to custom widgets.

+ +

Prerequisites

+ +

Before starting this module, you should at least work through our Introduction to HTML. At this point you should find the {{anch("Basic guides")}} easy to understand, and also be able to make use of our Native form widgets guide.

+ +

The rest of the module however is a bit more advanced — it is easy to put form widgets on a page, but you can't actually do much with them without using some advanced form features, CSS, and JavaScript. Therefore, before you look at the other sections we'd recommend that you go away and learn some CSS and JavaScript first.

+ +
+

Note: If you are working on a computer/tablet/other device where you don't have the ability to create your own files, you could try out (most of) the code examples in an online coding program such as JSBin or Thimble.

+
+ +

Basic guides

+ +
+
Your first HTML form
+
The first article in our series provides your very first experience of creating an HTML form, including designing a simple form, implementing it using the right HTML elements, adding some very simple styling via CSS, and how data is sent to a server.
+
How to structure an HTML form
+
With the basics out of the way, we now look in more detail at the elements used to provide structure and meaning to the different parts of a form.
+
+ +

What form widgets are available?

+ +
+
The native form widgets
+
We now look at the functionality of the different form widgets in detail, looking at what options are available to collect different types of data.
+
+ +

Validating and submitting form data

+ +
+
Sending form data
+
This article looks at what happens when a user submits a form — where does the data go, and how do we handle it when it gets there? We also look at some of the security concerns associated with sending form data.
+
Form data validation
+
Sending data is not enough — we also need to make sure that the data users fill out in forms is in the correct format we need to process it successfully, and that it won't break our applications. We also want to help our users to fill out our forms correctly and don't get frustrated when trying to use our apps. Form validation helps us achieve these goals — this article tells you what you need to know.
+
+ +

Advanced guides

+ +
+
How to build custom form widgets
+
You'll come across some cases where the native form widgets just don't provide what you need, e.g. because of styling or functionality. In such cases, you may need to build your own form widget out of raw HTML. This article explains how you'd do this and the considerations you need to be aware of when doing so, with a practical case study.
+
Sending forms through JavaScript
+
This article looks at ways to use a form to assemble an HTTP request and send it via custom JavaScript, rather than standard form submission. It also looks at why you'd want to do this, and the implications of doing so. (See also Using FormData objects.)
+
HTML forms in legacy browsers
+
Article covering feature detection, etc. This should be redirected to the cross browser testing module, as the same stuff is covered better there.
+
+ +

Form styling guides

+ +
+
Styling HTML forms
+
This article provides an introduction to styling forms with CSS, including all the basics you might need to know for basic styling tasks.
+
Advanced styling for HTML forms
+
Here we look at some more advanced form styling techniques that need to be used when trying to deal with some of the more difficult-to-style elements.
+
Property compatibility table for form widgets
+
This last article provides a handy reference allowing you to look up what CSS properties are compatible with what form elements.
+
+ +

See also

+ + diff --git a/files/my/learn/html/forms/your_first_form/index.html b/files/my/learn/html/forms/your_first_form/index.html new file mode 100644 index 0000000000..03f72249e9 --- /dev/null +++ b/files/my/learn/html/forms/your_first_form/index.html @@ -0,0 +1,298 @@ +--- +title: ပထမဆုံး Form +slug: Learn/HTML/Forms/Your_first_form +translation_of: Learn/Forms/Your_first_form +--- +
{{LearnSidebar}}{{NextMenu("Learn/Forms/How_to_structure_a_web_form", "Learn/Forms")}}
+ +

Web form တစ်ခုဖန်တီးဖို့အတွက် ပထမဆုံးအတွေ့အကြုံကို ဆောင်းပါးစီးရီးရဲ့ ပထမဦးဆုံးသော ဒီဆောင်းပါးမှာ ရရှိမှာပါ။,  HTML form controls တွေနဲ့ အခြား HTML elements တွေကိုမှန်ကန်စွာအသုံးချပြီး ရိုးရိုး form တစ်ခုကို ဒီဇိုင်းပုံဖော်ခြင်းနဲ့ လက်တွေ့ရေးဆွဲရပါမယ်။ CSS ကိုသုံးပြီး အဲဒီ Form ကို ရိုးရိုးလေး အလှဆင်တာနည်းနည်းလုပ်ရမယ်။ ဆာဗာကို ဒေတာတွေဘယ်လိုပို့သလဲဆိုတာလည်း လေ့လာရပါမယ်။ အပေါ်မှာပြောခဲ့တာတွေ တစ်ခုချင်းစီကို နောက်ပိုင်းမှာ နည်းနည်းပိုပြီးအသေးစိတ်ရှင်းပြပေးသွားပါမယ်။

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, and a basic understanding of HTML.
Objective:To gain familiarity with what web forms are, what they are used for, how to think about designing them, and the basic HTML elements you'll need for simple cases.
+ +

What are web forms?

+ +

Web forms are one of the main points of interaction between a user and a web site or application. Forms allow users to enter data, which is generally sent to a web server for processing and storage (see Sending form data later in the module), or used on the client-side to immediately update the interface in some way (for example, add another item to a list, or show or hide a UI feature).

+ +

A web form's HTML is made up of one or more form controls (sometimes called widgets), plus some additional elements to help structure the overall form — they are often referred to as HTML forms. The controls can be single or multi-line text fields, dropdown boxes, buttons, checkboxes, or radio buttons, and are mostly created using the {{htmlelement("input")}} element, although there are some other elements to learn about too.

+ +

Form controls can also be programmed to enforce specific formats or values to be entered (form validation), and paired with text labels that describe their purpose to both sighted and blind users.

+ +

Designing your form

+ +

Before starting to code, it's always better to step back and take the time to think about your form. Designing a quick mockup will help you to define the right set of data you want to ask your user to enter. From a user experience (UX) point of view, it's important to remember that the bigger your form, the more you risk frustrating people and losing users. Keep it simple and stay focused: ask only for the data you absolutely need.

+ +

Designing forms is an important step when you are building a site or application. It's beyond the scope of this article to cover the user experience of forms, but if you want to dig into that topic you should read the following articles:

+ + + +

In this article, we'll build a simple contact form. Let's make a rough sketch.

+ +

The form to build, roughly sketch

+ +

Our form will contain three text fields and one button. We are asking the user for their name, their e-mail and the message they want to send. Hitting the button will send their data to a web server.

+ +

Active learning: Implementing our form HTML

+ +

Ok, let's have a go at creating the HTML for our form. We will use the following HTML elements: {{HTMLelement("form")}}, {{HTMLelement("label")}}, {{HTMLelement("input")}}, {{HTMLelement("textarea")}}, and {{HTMLelement("button")}}.

+ +

Before you go any further, make a local copy of our simple HTML template — you'll enter your form HTML into here.

+ +

The {{HTMLelement("form")}} element

+ +

All forms start with a {{HTMLelement("form")}} element, like this:

+ +
<form action="/my-handling-form-page" method="post">
+
+</form>
+ +

This element formally defines a form. It's a container element like a {{HTMLelement("section")}} or {{HTMLelement("footer")}} element, but specifically for containing forms; it also supports some specific attributes to configure the way the form behaves. All of its attributes are optional, but it's standard practice to always set at least the action and method attributes:

+ + + +
+

Note: We'll look at how those attributes work in our Sending form data article later on.

+
+ +

For now, add the above {{htmlelement("form")}} element into your HTML {{htmlelement("body")}}.

+ +

The {{HTMLelement("label")}}, {{HTMLelement("input")}}, and {{HTMLelement("textarea")}} elements

+ +

Our contact form is not complex: the data entry portion contains three text fields, each with a corresponding {{HTMLelement("label")}}:

+ + + +

In terms of HTML code we need something like the following to implement these form widgets:

+ +
<form action="/my-handling-form-page" method="post">
+ <ul>
+  <li>
+    <label for="name">Name:</label>
+    <input type="text" id="name" name="user_name">
+  </li>
+  <li>
+    <label for="mail">E-mail:</label>
+    <input type="email" id="mail" name="user_email">
+  </li>
+  <li>
+    <label for="msg">Message:</label>
+    <textarea id="msg" name="user_message"></textarea>
+  </li>
+ </ul>
+</form>
+ +

Update your form code to look like the above.

+ +

The {{HTMLelement("li")}} elements are there to conveniently structure our code and make styling easier (see later in the article). For usability and accessibility, we include an explicit label for each form control. Note the use of the for attribute on all {{HTMLelement("label")}} elements, which takes as its value the id of the form control with which it is associated — this is how you associate a form control with its label.

+ +

There is great benefit to doing this — it associates the label with the form control, enabling mouse, trackpad, and touch device users to click on the label to activate the corresponding control, and it also provides an accessible name for screen readers to read out to their users. You'll find further details of form labels in How to structure a web form.

+ +

On the {{HTMLelement("input")}} element, the most important attribute is the type attribute. This attribute is extremely important because it defines the way the {{HTMLelement("input")}} element appears and behaves. You'll find more about this in the Basic native form controls article later on.

+ + + +

Last but not least, note the syntax of <input> vs. <textarea></textarea>. This is one of the oddities of HTML. The <input> tag is an empty element, meaning that it doesn't need a closing tag. {{HTMLElement("textarea")}} is not an empty element, meaning it should be closed with the proper ending tag. This has an impact on a specific feature of forms: the way you define the default value. To define the default value of an {{HTMLElement("input")}} element you have to use the value attribute like this:

+ +
<input type="text" value="by default this element is filled with this text">
+ +

On the other hand,  if you want to define a default value for a {{HTMLElement("textarea")}}, you put it between the opening and closing tags of the {{HTMLElement("textarea")}} element, like this:

+ +
<textarea>
+by default this element is filled with this text
+</textarea>
+ +

The {{HTMLelement("button")}} element

+ +

The markup for our form is almost complete; we just need to add a button to allow the user to send, or "submit", their data once they have filled out the form. This is done by using the {{HTMLelement("button")}} element; add the following just above the closing </ul> tag:

+ +
<li class="button">
+  <button type="submit">Send your message</button>
+</li>
+ +

The {{htmlelement("button")}} element also accepts a type attribute — this accepts one of three values: submit, reset, or button.

+ + + +
+

Note: You can also use the {{HTMLElement("input")}} element with the corresponding type to produce a button, for example <input type="submit">. The main advantage of the {{HTMLelement("button")}} element is that the {{HTMLelement("input")}} element only allows plain text in its label whereas the {{HTMLelement("button")}} element allows full HTML content, allowing more complex, creative button content.

+
+ +

Basic form styling

+ +

Now that you have finished writing your form's HTML code, try saving it and looking at it in a browser. At the moment, you'll see that it looks rather ugly.

+ +
+

Note: If you don't think you've got the HTML code right, try comparing it with our finished example — see first-form.html (also see it live).

+
+ +

Forms are notoriously tricky to style nicely. It is beyond the scope of this article to teach you form styling in detail, so for the moment we will just get you to add some CSS to make it look OK.

+ +

First of all, add a {{htmlelement("style")}} element to your page, inside your HTML head. It should look like so:

+ +
<style>
+
+</style>
+ +

Inside the style tags, add the following CSS:

+ +
form {
+  /* Center the form on the page */
+  margin: 0 auto;
+  width: 400px;
+  /* Form outline */
+  padding: 1em;
+  border: 1px solid #CCC;
+  border-radius: 1em;
+}
+
+ul {
+  list-style: none;
+  padding: 0;
+  margin: 0;
+}
+
+form li + li {
+  margin-top: 1em;
+}
+
+label {
+  /* Uniform size & alignment */
+  display: inline-block;
+  width: 90px;
+  text-align: right;
+}
+
+input,
+textarea {
+  /* To make sure that all text fields have the same font settings
+     By default, textareas have a monospace font */
+  font: 1em sans-serif;
+
+  /* Uniform text field size */
+  width: 300px;
+  box-sizing: border-box;
+
+  /* Match form field borders */
+  border: 1px solid #999;
+}
+
+input:focus,
+textarea:focus {
+  /* Additional highlight for focused elements */
+  border-color: #000;
+}
+
+textarea {
+  /* Align multiline text fields with their labels */
+  vertical-align: top;
+
+  /* Provide space to type some text */
+  height: 5em;
+}
+
+.button {
+  /* Align buttons with the text fields */
+  padding-left: 90px; /* same size as the label elements */
+}
+
+button {
+  /* This extra margin represent roughly the same space as the space
+     between the labels and their text fields */
+  margin-left: .5em;
+}
+ +

Save and reload, and you'll see that your form should look much less ugly.

+ +
+

Note: You can find our version on GitHub at first-form-styled.html (also see it live).

+
+ +

Sending form data to your web server

+ +

The last part, and perhaps the trickiest, is to handle form data on the server side. The {{HTMLelement("form")}} element defines where and how to send the data thanks to the action and method attributes.

+ +

We provide a name to each form control. The names are important on both the client- and server-side; they tell the browser which name to give each piece of data and, on the server side, they let the server handle each piece of data by name. The form data is sent to the server as name/value pairs.

+ +

To name the data in a form you need to use the name attribute on each form widget that will collect a specific piece of data. Let's look at some of our form code again:

+ +
<form action="/my-handling-form-page" method="post">
+ <ul>
+  <li>
+    <label for="name">Name:</label>
+    <input type="text" id="name" name="user_name" />
+  </li>
+  <li>
+    <label for="mail">E-mail:</label>
+    <input type="email" id="mail" name="user_email" />
+  </li>
+  <li>
+    <label for="msg">Message:</label>
+    <textarea id="msg" name="user_message"></textarea>
+  </li>
+
+  ...
+
+ +

In our example, the form will send 3 pieces of data named "user_name", "user_email", and "user_message". That data will be sent to the URL "/my-handling-form-page" using the HTTP POST method.

+ +

On the server side, the script at the URL "/my-handling-form-page" will receive the data as a list of 3 key/value items contained in the HTTP request. The way this script will handle that data is up to you. Each server-side language (PHP, Python, Ruby, Java, C#, etc.) has its own mechanism of handling form data. It's beyond the scope of this guide to go deeply into that subject, but if you want to know more, we have provided some examples in our Sending form data article later on.

+ +

Summary

+ +

Congratulations, you've built your first web form. It looks like this live:

+ +

{{ EmbedLiveSample('A_simple_form', '100%', '240', '', 'Learn/Forms/Your_first_form/Example') }}

+ +

That's only the beginning, however — now it's time to take a deeper look. Forms have way more power than what we saw here and the other articles in this module will help you to master the rest.

+ +

{{NextMenu("Learn/Forms/How_to_structure_a_web_form", "Learn/Forms")}}

+ +

In this module

+ + + +

Advanced Topics

+ + diff --git a/files/my/learn/html/index.html b/files/my/learn/html/index.html new file mode 100644 index 0000000000..efe1fad267 --- /dev/null +++ b/files/my/learn/html/index.html @@ -0,0 +1,52 @@ +--- +title: HTML +slug: Learn/HTML +translation_of: Learn/HTML +--- +
{{LearnSidebar}}
+ +

To build websites, you should know about {{Glossary('HTML')}} — the fundamental technology used to define the structure of a webpage. HTML is used to specify whether your web content should be recognized as a paragraph, list, heading, link, image, multimedia player, form, or one of many other available elements or even a new element that you define.

+ +

သင်ယူမုဆိုင်ရာ လမ်းေကာင်း

+ +

Ideally you should start your learning journey by learning HTML. Start by reading Introduction to HTML. You may then move on to learning about more advanced topics such as:

+ + + +
+
+ +

Before starting this topic, you should have at least basic familiarity with using computers, and using the web passively (i.e. just looking at it, consuming the content). You should have a basic work environment set up as detailed in Installing basic software, and understand how to create and manage files, as detailed in Dealing with files — both are parts of our Getting started with the web complete beginner's module.

+ +

It is recommended that you work through Getting started with the web before attempting this topic, however it isn't absolutely necessary; much of what is covered in the HTML basics article is also covered in our Introduction to HTML module, albeit in a lot more detail.

+ +

သင်ရိုး

+ +

This topic contains the following modules, in a suggested order for working through them. You should definitely start with the first one.

+ +
+
Introduction to HTML
+
This module sets the stage, getting you used to important concepts and syntax, looking at applying HTML to text, how to create hyperlinks, and how to use HTML to structure a webpage.
+
Multimedia and embedding
+
This module explores how to use HTML to include multimedia in your web pages, including the different ways that images can be included, and how to embed video, audio, and even entire other webpages.
+
HTML Tables
+
Representing tabular data on a webpage in an understandable, {{glossary("Accessibility", "accessible")}} way can be a challenge. This module covers basic table markup, along with more complex features such as implementing captions and summaries.
+
HTML Forms
+
Forms are a very important part of the Web — these provide much of the functionality you need for interacting with web sites, e.g. registering and logging in, sending feedback, buying products, and more. This module gets you started with creating the client-side parts of forms.
+
+ +

 HTML ပသနာများ ေဖရင်းခင်း

+ +

Use HTML to solve common problems provides links to sections of content explaining how to use HTML to solve very common problems when creating a webpage: dealing with titles, adding images or videos, emphasizing content, creating a basic form, etc.

+ +

ပိုမိုလေ့လာရန်

+ +
+
+
HTML (HyperText Markup Language) on MDN
+
The main entry point for HTML documentation on MDN, including detailed element and attribute references — if you want to know what attributes an element has or what values an attribute has, for example, this is a great place to start.
+
+
diff --git a/files/my/learn/index.html b/files/my/learn/index.html new file mode 100644 index 0000000000..367d375f74 --- /dev/null +++ b/files/my/learn/index.html @@ -0,0 +1,89 @@ +--- +title: Web developement အကြောင်းလေ့လာခြင်း +slug: Learn +tags: + - Beginner + - Index + - Landing + - Learn + - Web +translation_of: Learn +--- +
+

vbnကိုယ်တိုင် website တစ်ခု ဒါမှမဟုတ် web app တခုဖန်တီးချင်တယ်ဟုတ်။ ဒီနေရာကသင့်ကိုစောင့်နေပါတယ်။

+
+ +

web design နဲ့ development အတွက် သင်ယူစရာတွေများပပြားလှပါတယ်။ ဒါပေမဲ့ စိတ်မပူပါနဲ့ ။ ကျွန်တော်တို့ သင့်ကို professional web developer တယောက်အဖြစ်ရပ်တည်နိုင်လာအောင် ကူညီလမ်းပြပေးမှာပါ။

+ +

ဘယ်​နေ​အစ​ပြုချင်လဲ

+ +

ခ​င်​ဗျားနဲ့ ကျွန်တော်တို့တော့ ဆုံကြပြီ၊ ဘယ်အကြောင်းအရာကိုခ​င်ဗျားလေ့လာချင်ပါသလဲ။

+ + + +
+

Note: In the future, we're planning to publish more learning pathways, for example for experienced coders learning specific advanced techniques, native developers who are new to the Web, or people who want to learn design techniques.

+
+ +

{{LearnBox({"title":"Quick learning: Vocabulary"})}}

+ +

Learning with other people

+ +

If you have a question or are still wondering where to go, Mozilla is a global community of Web enthusiasts, including mentors and teachers who are glad to help you. Get in touch with them through WebMaker:

+ + + +

Sharing knowledge

+ +

This whole Learning Area is built by our contributors. We need you in our team whether you are a beginner, a teacher, or a skilled web developer. If you're interested, take a look at how you can help, and we encourage you to chat with us on our mailing lists or IRC channel. :)

+ + + +
    +
  1. Web နှင့်အစပြုကြရအောင်
  2. +
  3. Web အကြောင်းသိကောင်းစရာ +
      +
    1. Web Literacy Map
    2. +
    3. Web mechanics
    4. +
    5. Infrastructure
    6. +
    7. Coding & Scripting
    8. +
    9. Design & Accessibility
    10. +
    11. Writing & planning
    12. +
    +
  4. +
  5. နည်းပညာများ လေ့လာမယ် +
      +
    1. HTML
    2. +
    3. CSS
    4. +
    5. JavaScript
    6. +
    7. Python
    8. +
    +
  6. +
  7. သင်ခန်းစာများနှင့် လေ့လာမယ် +
      +
    1. Website တစ်ခုဘယ်လိုတည်ဆောက်မလဲ
    2. +
    3. Information security အခြေခံ
    4. +
    +
  8. +
  9. သင်ယူမှုအရင်းအမြစ်များရယူရန်
  10. +
  11. အကူအညီရယူရန် +
      +
    1. FAQ
    2. +
    3. Glossary
    4. +
    5. Ask your questions
    6. +
    7. Meet teachers and mentors
    8. +
    +
  12. +
  13. ကျွန်တော်တို့ကို ကူညီ ထောက်ပံပါ
  14. +
diff --git a/files/my/learn/javascript/index.html b/files/my/learn/javascript/index.html new file mode 100644 index 0000000000..2e6649a258 --- /dev/null +++ b/files/my/learn/javascript/index.html @@ -0,0 +1,66 @@ +--- +title: JavaScript +slug: Learn/JavaScript +tags: + - Beginner + - CodingScripting + - JavaScript + - JavaScripting beginner + - Landing + - Module + - NeedsTranslation + - Topic + - TopicStub + - 'l10n:priority' +translation_of: Learn/JavaScript +--- +
{{LearnSidebar}}
+ +

{{Glossary("JavaScript")}} is a programming language that allows you to implement complex things on web pages. Every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, or interactive maps, or animated 2D/3D graphics, or scrolling video jukeboxes, and so on — you can bet that JavaScript is probably involved.

+ +

Learning pathway

+ +

JavaScript is arguably more difficult to learn than related technologies such as HTML and CSS. Before attempting to learn JavaScript, you are strongly advised to get familiar with at least these two technologies first, and perhaps others as well. Start by working through the following modules:

+ + + +

Having previous experience with other programming languages might also help.

+ +

After getting familiar with the basics of JavaScript, you should be in a position to learn about more advanced topics, for example:

+ + + +

Modules

+ +

This topic contains the following modules, in a suggested order for working through them.

+ +
+
JavaScript first steps
+
In our first JavaScript module, we first answer some fundamental questions such as "what is JavaScript?", "what does it look like?", and "what can it do?", before moving on to taking you through your first practical experience of writing JavaScript. After that, we discuss some key JavaScript features in detail, such as variables, strings, numbers and arrays.
+
JavaScript building blocks
+
In this module, we continue our coverage of all JavaScript's key fundamental features, turning our attention to commonly-encountered types of code block such as conditional statements, loops, functions, and events. You've seen this stuff already in the course, but only in passing — here we'll discuss it all explicitly.
+
Introducing JavaScript objects
+
In JavaScript, most things are objects, from core JavaScript features like strings and arrays to the browser APIs built on top of JavaScript. You can even create your own objects to encapsulate related functions and variables into efficient packages. The object-oriented nature of JavaScript is important to understand if you want to go further with your knowledge of the language and write more efficient code, therefore we've provided this module to help you. Here we teach object theory and syntax in detail, look at how to create your own objects, and explain what JSON data is and how to work with it.
+
Client-side web APIs
+
When writing client-side JavaScript for web sites or applications, you won't go very far before you start to use APIs — interfaces for manipulating different aspects of the browser and operating system the site is running on, or even data from other web sites or services. In this module we will explore what APIs are, and how to use some of the most common APIs you'll come across often in your development work. 
+
+ +

Solving common JavaScript problems

+ +

Use JavaScript to solve common problems provides links to sections of content explaining how to use JavaScript to solve very common problems when creating a webpage.

+ +

See also

+ +
+
JavaScript on MDN
+
The main entry point for core JavaScript documentation on MDN — this is where you'll find extensive reference docs on all aspects of the JavaScript language, and some advanced tutorials aimed at experienced JavaScripters.
+
Coding math
+
An excellent series of video tutorials to teach the math you need to understand to be an effective programmer, by Keith Peters.
+
diff --git a/files/my/mozilla/index.html b/files/my/mozilla/index.html new file mode 100644 index 0000000000..ddb9a6605f --- /dev/null +++ b/files/my/mozilla/index.html @@ -0,0 +1,12 @@ +--- +title: Mozilla +slug: Mozilla +tags: + - Landing + - Mozilla + - NeedsTranslation + - TopicStub +translation_of: Mozilla +--- +

The articles below include content about downloading and building Mozilla code. In addition, you'll find helpful articles about how the code works, how to build add-ons for Mozilla applications and the like.

+

{{LandingPageListSubpages}}

diff --git a/files/my/mozilla/localization/index.html b/files/my/mozilla/localization/index.html new file mode 100644 index 0000000000..73cded6c42 --- /dev/null +++ b/files/my/mozilla/localization/index.html @@ -0,0 +1,17 @@ +--- +title: Localization at Mozilla +slug: Mozilla/Localization +translation_of: Mozilla/Localization +--- +

In progress. Localization (L10n) is the process of translating software user interfaces from one language to another and adapting it to suit a foreign culture. These resources are for anyone with an interest in the technical aspects involved in localization. They are for developers and all contributors.

+ +

See also

+ +
+
Localizing MDN
+
This resource covers localization of the documentation here on MDN.
+
App localization
+
This set of documents applies more specifically to localizing apps, including Firefox OS apps.
+
L10n
+
Reference docs for the L10n API that Mozilla uses to localise Firefox OS.
+
diff --git a/files/my/mozilla/localization/l10n_style_guide/index.html b/files/my/mozilla/localization/l10n_style_guide/index.html new file mode 100644 index 0000000000..d8d9e74f31 --- /dev/null +++ b/files/my/mozilla/localization/l10n_style_guide/index.html @@ -0,0 +1,485 @@ +--- +title: Mozilla L10n ပုံစံပြလမ်းညွှန် +slug: Mozilla/Localization/L10n_Style_Guide +translation_of: Mozilla/Localization/L10n_Style_Guide +--- +

မိတ်ဆက်

+ +
Style guides define the standard against which we determine a translation's quality. They contain rules that are both defined by Mozilla and by Mozilla's localization communities on how to best translate text in Mozilla products, websites, and other projects. Style guides are used to both translate and evaluate a translation's quality. By following these rules, a translator has a better chance of producing a high quality translation that represents Mozilla values and culture. Some examples of international style guides created by other organizations are:
+ + + +
This style guide is broken up into two main parts: the first contains rules that are language-specific and must be defined by each Mozilla l10n community (covering language-specific style, terminology, and units); the second contains general rules that Mozilla has defined for translators of all languages that can help you translate well (covering principles of accuracy and fluency). Please adapt part one of this style guide to your l10n community's rules for style, terminology, and units. Wherever possible, refer to existing national standards for units, spelling, and grammar in your community's adaptation of the first part of this style guide.
+ +

 

+ +

Language-specific Mozilla style

+ +
    +
+ +

ပုံစံ

+ +
Your localization community's style is largely up to you to define. It is a part of your community's instructions and standards for translating strings within each project type. Style encompasses various elements, such as formality, tone, natural expression, handling cultural references, idioms, or slang, and maintaining consistency with Mozilla and 3rd party branding and style guides. Your localization community should define these style elements for localizing Mozilla projects into your language. Let's go through these main aspects of Style.
+ +
 
+ +
Formality and Tone
+ +
When determining the formality or tone of a Mozilla l10n project in your language, ask yourself these questions:
+ + + +
In fact, localization should not use a level of formality higher or lower than required by this community-defined style guideline. An example of this would be using "click here" (not formal) vs. "please click here" (more formal). Also, the tone employed throughout a l10n project(s) should stay consistent within itself. 
+ +
 
+ +
Natural expression
+ +
Using natural expressions make your localization sound natural to a native speaker. If your translation does not follow the community defined language guidelines for translating content that contains local or natural expressions, this results in a mediocre and/or awkward translation. Teams should be careful to address those and keep them in mind while translating, which is why it is an important section to address in a Style Guide. An example of a natural expression in a translation would be translating the Spanish phrase, "En ocho días." In English, one might translate this as, "in eight days" or "in a week." The latter is the more natural translation, although both could be considered correct.
+ +
 
+ +
In this section, form guidelines for how to perform a natural sounding localization. This might take some time and experience to find the right examples to include or create the right guidelines for your language.
+ +
 
+ +
Handling cultural references, idioms, and slang
+ +

Cultural references, idioms, and slang require a full understanding of these references between the cultures of your source and target languages. An example of a cultural reference in English would be the phrase, "kick-off meeting." This is a reference that uses an American football term. It means a meeting to begin a project. To translate it, you can follow one of two approaches:

+ +
    +
  1. Find an equivalent reference phrase in your language.
  2. +
  3. Remove the cultural reference and translate the core meaning (e.g., "a commencement meeting") 
  4. +
+ +

Define a policy for handling these cultural references, idioms, and slang that you can make standard across all projects. Consider resources you can refer back to in order to find cultural equivalents and list them in this section of your style guide (e.g., a slang dictionary in your language).  

+ +
Style consistency
+ +
Finally, adherence to Mozilla and third-party branding and style guides should be respected throughout a localization project. More information on Mozilla-specific branding rules can be found here: https://www.mozilla.org/en-US/styleguide/identity/firefox/branding/. For example, some brand names should never be translated, such as "Firefox".  For other brands that do not have any branding guidelines, your localization community must define whether to translate them. Be extra careful to check on branding rules before deciding to translate a name or not (whether for Mozilla or for a third-party) and to list them here in your community's l10n style guide.
+ +
 
+ +
+

ပညာရပ်ဝေါဟာရ

+ +
Here are a few existing term bases we approve of for software/internet terminology and definitions (though not limited to):
+ + + +
You should be consistent in the use of existing reliable appropriate term bases in your language.  These term bases could be developed and approved by the community, or leveraged from another party that adhere to national, international or local standards for software and internet terminology.  Avoid the following:
+ + + +
Tips on translating difficult concepts
+ +
Translating terms representing difficult concepts is a tricky task. Here are some ideas to help you translate terms that do not have equivalents in your language:
+ + + +
Developing new term bases
+ +
What is your community's process for identifying and creating a new termbase? Here are a few things to keep in mind:
+ + + +

အတိုင်းအတာနှင့် သဒ္ဒါ

+ +
Many elements of unit or grammar do not exist or apply to all languages. If you find one of these elements that does not apply to your language, please remove it from your style guide. For those definitions of units and grammar that apply document the reference used or how it will be applied to the translation.
+ +
 
+ +
The translation should strive to achieve proper unit conversions for currency, measurements, etc. for the target audience.
+ +
 
+ +

Units and Unit Conversion

+ +
Date Format
+ +
How are the date formats for weeks and months expressed in the following forms:
+ + + +
Reference material can be find here: https://en.wikipedia.org/wiki/Date_format_by_country
+ +
 
+ +
Calendar view: 
+ + + +
Time Format
+ +
How is time expressed in your language? Including 0-24 hr expression, hour, minute and second.
+ +
 
+ +
Numerals 
+ +
How are numerals and percentages expressed in your language? 
+ +
    Example: 1.23 (decimal separator) or 1,000 (thousand separator) using comma or period. 
+ +
 
+ +
Currency 
+ +
What are other widely used currency and symbols used in your country/language for paid apps. 
+ +
 
+ +
Units
+ +
Do you use the imperial, metric or nautical system for measuring weight, distance, etc.? Source strings will use the imperial system (e.g., miles, pounds, feet, gallons, etc.). Target translations should convert imperial metrics to their measurement system.
+ +
 
+ +
Names  
+ +
+

What are the order of family name and given name in your language?  Here is the guideline on the naming convention from w3c.org:

+
+ +
Address and Postal Code Format 
+ +
What is the format in your language?  
+ +
    Example: most Asian countries start from big to small: [Country] [postal code][state/province][city][district][street number and name][building and suite numbers][addressee]
+ +
    Countries of European languages start from small to big: [addressee][street number and name][building and suite numbers][district][city][state/province][postal code][Country]
+ +
   
+ +
Telephone Number format
+ +
Space separators between digits can be different for area codes such as State (Province) and City,
+ +
 
+ +

Spelling And Grammar Checks

+ +
Many languages have national or international standards that define spelling and grammar rules. When defining these rules for your community, make reference to those standards wherever possible. Do you have automated tests for spell checking and grammar? List those tools and dictionaries here and how regularly they should be used.
+ +
 
+ +
Tense
+ +
Do you have standards for verb forms that indicate or express the time, such as past, present, or future, of the action or state? What is your policy on tense consistency for certain use cases? For example, for phrases that ask a user to make an action (like "Download Firefox"), do you use a future tense, a command tense, or a neutral tense?  (See: https://en.wikipedia.org/wiki/Grammatical_tense )
+ +
 
+ +

Word Forms

+ +
Pluralization  
+ +
What is the appropriate form of expressing pluralization in your language?  List all forms of plural forms and examples if there is more than one.  Additional discussions can be found Here. https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals and here:  http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
+ +
 
+ +
Abbreviations  
+ +

How are abbreviations expressed in your language?
+     Example, in English, abbreviations are made by removing most vowels and only using the first 3-5 consonants followed by a period (e.g., abbreviation = abbr.).  (see: https://en.wikipedia.org/wiki/Abbreviation)    

+ +

If your language does not have a standard way of expressing abbreviations, do you simply leave them in English?

+ +
Acronyms 
+ +
+

Are there standard translations of widely accepted acronyms such as CD, DVD, MB in your language? If not, do they remain in English? (see: https://en.wikipedia.org/wiki/Acronym )

+
+ +
Punctuation
+ +
Do you use different punctuation rules in your Firefox localization than what your language standard defines?
+ +
    Example: do you use a period at the end of every user interface element translation or only some? What is the international/national standard for punctuation in your language?
+ +
 
+ +
Emphasis
+ +

Is there an international/national standard for capitalization in your language?

+ + + +
Hyphens and compounds 
+ +
What is the appropriate way of using hyphens and compounds in your language?  ( https://en.wikipedia.org/wiki/Compound_%28linguistics%29
+ +
 
+ +
Prepositions and articles 
+ +
What is the appropriate form of expressing prepositions and articles in your language?
+ +
 
+ +
Diacritics and Special characters  
+ +
Does your language use any special or accented characters and will they be applied and preserved in sort orders, and other aspects of the translation?  (see: https://en.wikipedia.org/wiki/Diacritic )
+ +
 
+ +
Quotes  
+ +
+

Does your language have a standard use for quotation marks, parenthesis, or brackets?

+
+ +
Whitespace 
+ +
+

Does your language require the use of white space around words, sentences, paragraphs, etc.? If so, in what ways?  (see: https://en.wikipedia.org/wiki/Sentence_spacing_in_language_and_style_guides )

+
+ +
User Interface Elements        
+ +
 
+ + +
+ +

အထွေထွေ Mozilla l10n ပုံစံ

+ +

မှန်ကန်မှု

+ +

Meaning-based translation

+ +
When it comes to translation, meaning is everything. A translator needs to understand the source text's meaning exactly. You then find its most closely linked equivalent in your own language, without adding or subtracting meaning in your translation. Finding meaning-based equivalents between languages can be difficult. To help concentrate your thoughts, ask yourself questions like:
+ + + +

Sometimes translation memory and machine translation tools can offer bad suggestions for a translation. If you use either as part of your translation workflow, make sure to correct the suggestions before submitting them. Avoid literal translation at all costs. Watch out for words that might sound or look the same between English and your language, but have a different meaning.

+ +

Should not be translated

+ +
Shortcuts and accesskeys
+ +

In Firefox and other software it's possible to use keyboard shortcuts to invoke a specific command. For example, to open a file in Firefox you can press the combination of keys CTRL+O (Cmd+O on Mac). The accelerator key depends on the operative system, but the letter itself is normally localizable. This is what is called a shortcut, or commandkey. For example, the Open File… menu item is stored as

+ +
<!ENTITY openFileCmd.label "Open File…">
+<!ENTITY openFileCmd.accesskey "O">
+<!ENTITY openFileCmd.commandkey "o">
+ +

The commandkey is stored in openFileCmd.commandkey (sometimes the string has .key in the identifier). Normally you should not localize this key, since shortcuts are often common across the entire operative system (e.g. CTRL+S to Save) or similar products (CTRL+T to open a new tab in most browsers). But it needs to be localized if the letter is not available in your keyboard layout. For example, in Italian the character [ can be accessed through ALT+è, a command key [ would not work.

+ +

In the code fragment above you see also an accesskey defined for Open File…. Accesskeys are used to access a UI element from the keyboard. Example: if File menu has an accesskey F, and the Open file… menu has O, you can press ALT+F to access the menu, and then O to open a file.

+ +

If the label is File, and the accesskey is F, it will be displayed as "File" on Windows and Linux, with an underscored F. If the accesskey was "O", so a character not available in the original label, it will be displayed underlined between parenthesis: "File (O)".

+ +

One important thing to determine is if, for your locale, it makes sense to have localized accesskeys: for example, if most users will use a keyboard with a different layout (English), it might make sense to keep the English original accesskey instead of using a letter available in your localization.

+ +

Accesskeys, like commandkeys, have their own lines within .dtd and .properties files and are usually identified by .accesskey in the string ID.

+ +
Variables
+ +

Variables should never be translated. You can recognize a variable within a string by its beginning with a specific character (e.g., $, #, %, etc.) followed by a combination of words without spacing. For example, $BrandShortName and %S are variables.  You can move a variable around within a string, if the translation of the string requires it.

+ + + +

Brand names, as well as copyright and trademarks should never be translated, nor transliterated into a non-Latin based script. See the Mozilla branding guide for more details.

+ +

Translating culture-specific references

+ +

At times there will be English content included in Mozilla products or web projects (e.g., marketing campaigns) that makes references to American culture and concepts. When translating these, it is best to find an equivalent cultural reference within your own culture that accurately conveys the meaning of the English reference. For example, an American might say, "Good job, home run!" A home run is a baseball reference for a successful outcome. An appropriate translation would be an equivalent metaphor within your culture. Using soccer as an example, you might translate "Good job, home run!" into "Good job, nice goal!" in your language.

+ +

[Add a note about Mozilla culture.]

+ + + +

Mozilla projects will often contain legal content in the form of user agreements, privacy statements, etc. When reviewing the translation of legal content, Mozilla localizers should do so according to the criteria concerning accuracy, fluency, style, and terminology found within this style guide and according to Mozilla culture and values.

+ +

ကောင်းမွန်သော ပြန်ဆိုမှု

+ +
 
+ +
To produce a fluent translation, not only should the translation follow the language's standard grammar, punctuation, and spelling rules, but it should avoid being ambiguous, incoherent, or inconsistent, and unintelligible.
+ +
 
+ +
To avoid ambiguity, the translator must thoroughly understand the meaning behind the source text, including any references that text might include. For example, if the English source text uses the word, "it", the translator must know what "it" is to avoid an ambiguous translation. Clearly understanding the source text will also allow a translator to make the source text's logical connections in their own translation. This helps to keep the translation coherent.
+ +
 
+ +
Inconsistency can pop up in many forms. A translator must be consistent in their use of abbreviations, references, and links within each localization project. They must also be consistent with Mozilla and the localization communities' style guides and approved terminology. Abbreviations, like terminology, should come from either a standard reference (like a dictionary of abbreviations) or should follow your language's rules for creating abbreviations. Once used, the abbreviation must remain consistent every place that it is used in the translation. Cross-references (or links) must also be consistently used within a translation. If a text contains a hyperlink URL to a support article in English, the translation should also contain a hyperlink to a translation of that support article (if available) or the English version. Links should not redirect to other pages nor should they be broken and unusable.
+ +
 
+ +
Finally, there are times that a translation simply doesn't make sense. It's hard to put your finger on what exactly is wrong with it, but you know it is unintelligible and not fluent. While this is uncommon, it's important to report these unintelligible translations and offer suggestions to correct them.
+ +
 
+ +

အခြားသိကောင်းစရာများ

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
အနက်ပြန်ခြင်း
၁။အနက်ပြန်သောကိစ္စ၌ မြန်မာလို ပြောဆိုရိုးဖြစ်သော စကားရှိလျှင် ထိုစကားမျိုးကို သုံးသင့်သည်။
၂။မျိုးခြား ဝေါဟာရတခုအတွက် မြန်မာဝေါဟာရတခုကို ပြုရာတွင် ထိုမျိုးခြားဝေါဟာရ၏ အဓိပ္ပါယ်တို့ကို အစုံပါစေလိုသော ဆန္ဒဖြင့် ပြုသောအခါ တခါတရံ မြန်မာမဆံခြင်း သော်လည်းကောင်း၊ ဆို၍ မကောင်းခြင်း သော်လည်းကောင်း ဖြစ်တန်ရာသည်။ ထိုအခါမျိုးတွင် အရေးကြီးဆုံးဖြစ်သော အဓိပ္ပါယ် တခု နှစ်ခုလောက်ကို သင့်တော်အောင် ပေါင်းစပ်၍ မြန်မာဝေါဟာရ ပြုသင့်သည်။
 (နောင်တနေ့တွင် ဝေါဟာရအဘိဓါန် စီရင်နိုင်လာသောအခါ ထိုစကားမျိုးအတွက် အသေးစိတ် အနက်ဖွင့်ရန် လိုပါလိမ့်မည်။)
၃။အနက်ပြန် ဝေါဟာရတခုသည် သုံးရိုးစွဲရိုးဖြစ်၍ ထိုဝေါဟာရကို လက်ခံခဲ့ကြပြီးဖြစ်လျှင် လက်ခံခဲ့ကြသည့်အတိုင်း ထားရှိသင့်သည်။ သို့ရာတွင် ခြွင်းချက်လည်း ရှိသင့်သည်။
အသံလှယ်ခြင်း 
၄။အသံလှယ်ရာ၌ သာမန်အားဖြင့် အင်္ဂလိပ်အသံထွက်ကို လှယ်သင့်ပါသည်။ (Daniel Jones ၏ English Pronouncing Dictionary ကို သုံးသင့်သည်။) သို့ရာတွင် ခြွင်းချက်လည်း ရှိသင့်သည်။
၅။မြန်မာ့နှုတ် အာလျှာတို့ဖြင့် ဆို၍ ကောင်းအောင် သို့မဟုတ် မြန်မာ့နားဖြင့် ကြား၍ ကောင်းအောင် အသံလှယ်သင့်သည်။
၆။သာမန်အားဖြင့် မျိုးခြားဝေါဟာရရှိ အဆုံးသတ်အသံအတိုင်း အသံလှယ်သင့်သည်။ သို့ရာတွင် အသံထွက်တူ၍ အနက်ကွဲပြားနေလျှင် ကွဲပြားချက်ထင်ရှားအောင် ပြုပြင်သင့်သည်။
၇။အသံလှယ် ဝေါဟာရတခုသည် သုံးရိုးစွဲရိုးဖြစ်၍ ထိုဝေါဟာရကို လက်ခံခဲ့ကြပြီးဖြစ်လျှင် လက်ခံခဲ့ကြသည့်အတိုင်း ထားရှိသင့်သည်။ သို့ရာတွင် ခြွင်းချက်လည်း ရှိသင့်သည်။
အထွေထွေ 
၈။ဝေါဟာရသည် သိလွယ်သော ဝေါဟာရ ဖြစ်သင့်သည်။ ကြားရုံမျှဖြင့် နားလည်သင့်သည်။
၉။သင့်တော်သည် ထင်မြင်လျှင် အရပ်သုံးစကားကိုပင် လက်ခံသင့်သည်။
၁၀။မျိုးခြားဝေါဟာရတခု၌ ပညာရပ်ကိုလိုက်၍ အဓိပ္ပါယ်တမျိုးစီ ရှိနေလျှင်
 (က)ပညာရပ်အလိုက် အဓိပ္ပါယ်ထွက်သော မြန်မာဝေါဟာရ တမျိုးစီ ရှိသင့်သည်။ သို့မဟုတ်
 (ခ)အသံလှယ်သင့်သည်။ သို့မဟုတ်
 (ဂ)ထိုမျိုးခြားဝေါဟာရ ပေါ်ထွက်ရာဖြစ်သော အရင်းခံပညာရပ်အလိုက် အနက်ပြန်၍ ဝေါဟာရပြုသင့်သည်။
၁၁။မျိုးခြားဝေါဟာရတခုအတွက် မြန်မာပြန် ဝေါဟာရနှင့် ပါဠိဝေါဟာရရှိနေလျှင် သာမန်အားဖြင့် မြန်မာဝေါဟာရကို ယူသင့်သည်။ မလွှဲမရှောင်မှသာလျှင် အသိလွယ်သော ပါဠိဝေါဟာရကို လက်ခံသင့်သည်။
၁၂။မျိုးခြားဝေါဟာရတခုအတွက် အနက်ပြန်ဝေါဟာရသော်လည်းကောင်း၊ အသံလှယ် ဝေါဟာရသော်လည်းကောင်း တခုလုံးထက် ပို၍ရှိနေလျှင် အသင့်တော်ဆုံးဟု ထင်ရသော တလုံးကို သာမန်အားဖြင့် ရွေးချယ်သင့်သည်။ သို့ရာတွင် လုံလောက်သော အကြောင်းရှိလျှင် ခြွင်းချက်လည်း ရှိသင့်သည်။
        
ဝေါဟာရဟူသည် နာမပညတ်မျှသာဖြစ်ရာ နာမပညတ်ကို ကြားသိရုံမျှဖြင့် သက်ဆိုင်ရာ အဓိပ္ပါယ်အလုံးစုံကို သိနိုင်မည် မဟုတ်ပါ။
+ ယခုညှိပြီး ဝေါဟာရတို့သည် ပြီးပြည့်စုံပြီဟု မယူဆသင့်ပါ။ ထပ်မံပြုပြင်စရာ၊ ဖြည့်စွက်စရာတို့ ရှိနေဦးမည်သာ ဖြစ်ပါသည်။ ထို့ကြောင့် ဤဝေါဟာရများကို သုံးသွားယင်း ပိုမိုကောင်းမွန်သော ဝေါဟာရများတွေ့ခဲ့သော် တက္ကသိုလ် ဘာသာပြန်နှင့် စာအုပ်ထုတ်ဝေရေးဌာနသို့ အကြံဉာဏ်ပေးပို့ကြရန် မေတ္တာရပ်ခံပါသည်။ ထိုသို့ ပေးပို့ကြသည့် အကြံဉာဏ်များအတိုင်း သင့်လျော်သလို ပြုပြင်ဖြည့်စွက်သွားမည် ဖြစ်ပါသည်။ စင်စစ်မှာ ဝေါဟာရပြုစုရေးလုပ်ငန်းသည် အစဉ်တစိုက် ဆက်၍ လုပ်ရဦးမည့်လုပ်ငန်းသာ ဖြစ်ပါသည်။
+ ဝိုင်းဝန်းပြုစုကြသည့် ပညာရှင်အားလုံးကို ကျေးဇူး ဥပကာရ တင်ပါကြောင်း
 
ရင်းမြစ်။
ပညာရေးဝန်ကြီးဌာန
+ အထက်တန်းပညာဦးစီးဌာန
+ တက္ကသိုလ်ပို့ချစာစဉ် (၃၆)
+ ပညာရေးတက္ကသိုလ်
+ ပညာရပ်ဝေါဟာရ
+ ၁၉၇၉
diff --git a/files/my/mozilla/performance/adding_a_new_telemetry_probe/index.html b/files/my/mozilla/performance/adding_a_new_telemetry_probe/index.html new file mode 100644 index 0000000000..b706bfd185 --- /dev/null +++ b/files/my/mozilla/performance/adding_a_new_telemetry_probe/index.html @@ -0,0 +1,184 @@ +--- +title: Adding a new Telemetry probe +slug: Mozilla/Performance/Adding_a_new_Telemetry_probe +translation_of: Mozilla/Performance/Adding_a_new_Telemetry_probe +--- +

If a user has opted into submitting performance data to Mozilla, the Telemetry system will collect various measures of Firefox performance, hardware, usage and customizations and submit it to Mozilla. The Telemetry data collected by a single client can be examined from the integrated about:telemetry browser page, while the aggregated reports across entire user populations are publicly available at https://telemetry.mozilla.org.

+ +
+

Note: Every new data collection in Firefox now needs a data collection review from a data collection peer. Just set the feedback? flag for :bsmedberg or one of the other data peers. We try to reply within a business day.

+
+ +

The following sections explain how to add a new measurement to Telemetry.

+ +

Telemetry Histograms

+ +

Telemetry histograms are the preferred way to track numeric measurements such as timings. Telemetry also tracks more complex data types such as slow SQL statement strings, browser hang stacks and system configurations. Most of these non-histogram measurements are maintained by the Telemetry team, so they are not covered in this document. If you need to add a non-histogram measurement, contact that team first.

+ +

The histogram below is taken from Firefox's about:telemetry page. It shows a histogram used for tracking plugin shutdown times and the data collected over a single Firefox session. The timing data is grouped into buckets where the height of the blue bars represents the number of items in each bucket. The tallest bar, for example, indicates that there were 63 plugin shutdowns lasting between 129ms and 204ms.

+ +

Sample Telemetry histogram "PLUGIN_SHUTDOWN_MS" taken from Firefox's about:telemetry page

+ +

Choosing a Histogram Type

+ +

The first step to adding a new histogram is to choose the histogram type that best represents the data being measured. The sample histogram used above is an "exponential" histogram.

+ +
+

Ony flag and count histograms have default values. All other histograms start out empty and are not submitted if no value is recorded for them.

+
+ +

The following types are available:

+ + + +

Keyed Histograms

+ +

Keyed histograms are collections of one of the histogram types above, indexed by a string key. This is for example useful when you want to break down certain counts by a name, like how often searches happen with which search engine.

+ +
+

Count histograms and keyed histograms are fully supported only in our V4 pipeline tools, such as the unified telemetry (v4) dashboards. These are not fully supported in Telemetry v2 pipeline tools such as the histogram change detector.

+
+ +

Declaring a Histogram

+ +

Histograms should be declared in the toolkit/components/telemetry/Histograms.json file. These declarations are checked for correctness at compile time and used to generate C++ code. It is also possible to create histograms at runtime dynamically, but this is primarily done by add-ons when they create their own histograms in Telemetry.

+ +

The following is a sample histogram declaration from Histograms.json for a histogram named MEMORY_RESIDENT which tracks the amount of resident memory used by a process:

+ +
"MEMORY_RESIDENT": {
+  "alert_emails": ["team@mozilla.xyz"],
+  "expires_in_version": "never",
+  "kind": "exponential",
+  "low": "32 * 1024",
+  "high": "1024 * 1024",
+  "n_buckets": 50,
+  "bug_numbers": [12345],
+  "description": "Resident memory size (KB)"
+},
+ +

Note that histogram declarations in Histograms.json are converted to C++ code so the right-hand sides of fields can be the names of C++ constants or simple expressions as in the "low" and "high" fields above.

+ +

The possible fields in a histogram declaration are:

+ + + +

Adding a JavaScript Probe

+ +

A Telemetry probe is the code that measures and stores values in a histogram. Probes in privileged JavaScript code can make use of the nsITelemetry interface to get references to histogram objects. A new value is recorded in the histogram by calling add on the histogram object:

+ +
let histogram = Services.telemetry.getHistogramById("PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS");
+histogram.add(measuredDuration);
+
+let keyed = Services.telemetry.getKeyedHistogramById("TAG_SEEN_COUNTS");
+keyed.add("blink");
+ +

For histogram measuring time, TelemetryStopwatch can also be used to avoid working with Dates manually:

+ +
TelemetryStopwatch.start("SEARCH_SERVICE_INIT_MS");
+TelemetryStopwatch.finish("SEARCH_SERVICE_INIT_MS");
+
+TelemetryStopwatch.start("FX_TAB_SWITCH_TOTAL_MS");
+TelemetryStopwatch.cancel("FX_TAB_SWITCH_TOTAL_MS");
+
+ +

Adding a C++ Probe

+ +

Probes in native code can also use the nsITelemetry interface, but the helper functions declared in Telemetry.h are more convenient:

+ +
#include "mozilla/Telemetry.h"
+
+/**
+ * Adds sample to a histogram defined in Histograms.json
+ *
+ * @param id - histogram id
+ * @param sample - value to record.
+ */
+void Accumulate(ID id, uint32_t sample);
+
+/**
+ * Adds time delta in milliseconds to a histogram defined in Histograms.json
+ *
+ * @param id - histogram id
+ * @param start - start time
+ * @param end - end time
+ */
+void AccumulateTimeDelta(ID id, TimeStamp start, TimeStamp end = TimeStamp::Now());
+ +

The histogram names declared in Histograms.json are translated into constants in the mozilla::Telemetry namespace:

+ +
mozilla::Telemetry::Accumulate(mozilla::Telemetry::STARTUP_CRASH_DETECTED, true);
+ +

The Telemetry.h header also declares the helper classes AutoTimer and AutoCounter. Objects of these types automatically record a histogram value when they go out of scope:

+ +
nsresult
+nsPluginHost::StopPluginInstance(nsNPAPIPluginInstance* aInstance)
+{
+  Telemetry::AutoTimer<Telemetry::PLUGIN_SHUTDOWN_MS> timer;
+  ...
+  return NS_OK;
+}
+
+ +

Miscellaneous

+ + diff --git a/files/my/mozilla/performance/index.html b/files/my/mozilla/performance/index.html new file mode 100644 index 0000000000..82c169862a --- /dev/null +++ b/files/my/mozilla/performance/index.html @@ -0,0 +1,143 @@ +--- +title: Performance +slug: Mozilla/Performance +tags: + - Add-ons + - Debugging + - Development + - Mozilla + - NeedsTranslation + - Performance + - TopicStub +translation_of: Mozilla/Performance +--- +

The articles linked to from here will help you improve performance, whether you're developing core Mozilla code or an add-on.

+ + + + + + + + +
+

Documentation

+ +
+
Reporting a Performance Problem
+
A user friendly guide to reporting a performance problem. A development environment is not required.
+
Benchmarking
+
Tips on generating valid performance metrics.
+
Performance best practices in extensions
+
A performance "best practices" guide for extension developers.
+
Measuring Add-on Startup Performance
+
A guide for add-on developers on how to set up a performance testing environment.
+
XUL School: Add-on Performance
+
Tips for add-on developers to help them avoid impairing application performance.
+
GPU performance
+
Tips for profiling and improving performance when using a GPU.
+
Scroll-Linked Effects
+
Information on scroll-linked effects, their effect on performance, related tools, and possible mitigation techniques.
+
Automated Performance Testing and Sheriffing
+
Information on automated performance testing and sheriffing at Mozilla.
+
+ +

View all pages tagged with "Performance"...

+ +

Memory profiling and leak detection tools

+ +
+
The Developer Tools "Memory" panel
+
The memory panel in the devtools supports taking heap snapshots, diffing them, computing dominator trees to surface "heavy retainers", and recording allocation stacks.
+
+ +
+
about:memory
+
about:memory is the easiest-to-use tool for measuring memory usage in Mozilla code, and is the best place to start. It also lets you do other memory-related operations like trigger GC and CC, dump GC & CC logs, and dump DMD reports. about:memory is built on top of Firefox's memory reporting infrastructure.
+
DMD
+
DMD is a tool that identifies shortcomings in about:memory's measurements, and can also do multiple kinds of general heap profiling.
+
areweslimyet.com
+
areweslimyet.com (a.k.a. AWSY) is a memory usage and regression tracker.
+
BloatView
+
BloatView prints per-class statistics on allocations and refcounts, and provides gross numbers on the amount of memory being leaked broken down by class. It is used as part of Mozilla's continuous integration testing.
+
Refcount tracing and balancing
+
Refcount tracing and balancing are ways to track down leaks caused by incorrect uses of reference counting. They are slow and not particular easy to use, and thus most suitable for use by expert developers.
+
GC and CC logs
+
GC and CC logs can be generated and analyzed to in various ways. In particular, they can help you understand why a particular object is being kept alive.
+
Valgrind
+
Valgrind is a tool that detects various memory-related problems at runtime, including leaks. Valgrind is used as part of Mozilla's continuous integration testing, though the coverage is limited because Valgrind is slow.
+
LeakSanitizer
+
LeakSanitizer (a.k.a. LSAN) is similar to Valgrind, but it runs faster because it uses static source code instrumentation. LSAN is part of Mozilla's continuous integration testing, with most tests running through it as part of the AddressSanitizer (a.k.a. ASAN) test jobs.
+
Apple tools
+
Apple provides some tools for Mac OS X that report similar problems to those reported by LSAN and Valgrind. The "leaks" tool is not recommended for use with SpiderMonkey or Firefox, because it gets confused by tagged pointers and thinks objects have leaked when they have not (see bug 390944).
+
Leak Gauge
+
Leak Gauge is a tool that can be used to detect certain kinds of leaks in Gecko, including those involving documents, window objects, and docshells.
+
LogAlloc
+
LogAlloc is a tool that dumps a log of memory allocations in Gecko. That log can then be replayed against Firefox's default memory allocator independently or through another replace-malloc library, allowing the testing of other allocators under the exact same workload.
+
Memory Profiler
+
The memory profiler samples allocation events and provides different views to analyze the allocation characteristic.
+
+ +

See also the documentation on Leak-hunting strategies and tips.

+
+

Profiling and performance tools

+ +
+
Profiling with the Developer Tools Profiler
+
The profiler built into the developer tools has a high-level waterfall, detailed call tree, allocations and GC profiling, and flame graphs. It is available on all platforms and release channels, and also supports remote profiling b2g and Fennec.
+
+ +
+
Profiling with the Gecko Profiler Addon {{ gecko_minversion_inline("16.0") }}
+
The Gecko Profiler Addon is a good tool to start with.
+
Profiling with Instruments
+
How to use Apple's Instruments tool to profile Mozilla code.
+
Profiling with Xperf
+
How to use Microsoft's Xperf tool to profile Mozilla code.
+
Profiling with Concurrency Visualizer
+
How to use Visual Studio's Concurrency Visualizer tool to profile Mozilla code.
+
Profiling with Zoom
+
Zoom is a profiler for Linux done by the people who made Shark
+
Measuring performance using the PerfMeasurement.jsm code module {{ gecko_minversion_inline("2.0") }}
+
Using PerfMeasurement.jsm to measure performance data in your JavaScript code.
+
Adding a new Telemetry probe
+
Information on how to add a new measurement to the Telemetry performance-reporting system
+
Profiling JavaScript with Shark (obsolete - replaced by Instruments)
+
How to use the Mac OS X Shark profiler to profile JavaScript code in Firefox 3.5 or later.
+
Profiling with Shark (obsolete - replaced by Instruments)
+
How to use Apple's Shark tool to profile Mozilla code.
+
Investigating CSS Performance
+
How to figure out why restyle is taking so long
+
+ +

Power profiling

+ +
+
Power profiling overview
+
This page provides an overview of relevant information, including details about hardware, what can be measured, and recommended approaches. It should be the starting point for anybody new to power profiling.
+
tools/power/rapl (Mac, Linux)
+
tools/power/rapl is a command-line utility in the Mozilla codebase that uses the Intel RAPL interface to gather direct power estimates for the package, cores, GPU and memory.
+
powermetrics (Mac-only)
+
powermetrics is a command-line utility that gathers and displays a wide range of global and per-process measurements, including CPU usage, GPU usage, and various wakeups frequencies.
+
TimerFirings logging (All platforms)
+
TimerFirings logging is a built-in logging mechanism that prints data on every time fired.
+
Activity Monitor, Battery Status Menu and top (Mac-only)
+
The battery status menu, Activity Monitor and top are three related Mac tools that have major flaws but often consulted by users, and so are worth understanding.
+
Intel Power Gadget (Windows, Mac, Linux)
+
Intel Power Gadget provides real-time graphs for package and processor RAPL estimates. It also provides an API through which those estimates can be obtained.
+
perf (Linux-only)
+
perf is a powerful command-line utility that can measure many different things, including energy estimates and high-context measurements of things such as wakeups.
+
turbostat (Linux-only)
+
turbostat is a command-line utility that gathers and displays various power-related measurements, with a focus on per-CPU measurements such as frequencies and C-states.
+
powertop (Linux-only)
+
powertop is an interactive command-line utility that gathers and displays various power-related measurements.
+
+ + + +
+
JavaScript, XPCOM, Developing Mozilla, Extensions, Addons
+
+
+ +

 

diff --git a/files/my/web/css/@font-face/index.html b/files/my/web/css/@font-face/index.html new file mode 100644 index 0000000000..69a0d3d8c9 --- /dev/null +++ b/files/my/web/css/@font-face/index.html @@ -0,0 +1,196 @@ +--- +title: '@font-face' +slug: Web/CSS/@font-face +translation_of: Web/CSS/@font-face +--- +
{{CSSRef}}
+ +

The @font-face CSS at-rule specifies a custom font with which to display text; the font can be loaded from either a remote server or a locally-installed font on the user's own computer.

+ +

Syntax

+ +
@font-face {
+  font-family: "Open Sans";
+  src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
+       url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
+}
+ +

Descriptors

+ +
+
{{cssxref("@font-face/font-display", "font-display")}}
+
Determines how a font face is displayed based on whether and when it is downloaded and ready to use.
+
{{cssxref("@font-face/font-family", "font-family")}}
+
Specifies a name that will be used as the font face value for font properties.
+
{{cssxref("@font-face/font-stretch", "font-stretch")}}
+
A {{cssxref("font-stretch")}} value. Since Firefox 61 (and in other modern browsers) this also accepts two values to specify a range that is supported by a font-face, for example font-stretch: 50% 200%;
+
{{cssxref("@font-face/font-style", "font-style")}}
+
A {{cssxref("font-style")}} value. Since Firefox 61 (and in other modern browsers) this also accepts two values to specify a range that is supported by a font-face, for example font-style: oblique 20deg 50deg;
+
{{cssxref("@font-face/font-weight", "font-weight")}}
+
A {{cssxref("font-weight")}} value. Since Firefox 61 (and in other modern browsers) this also accepts two values to specify a range that is supported by a font-face, for example font-weight: 100 400;
+
{{cssxref("@font-face/font-variant", "font-variant")}}
+
A {{cssxref("font-variant")}} value.
+
{{cssxref("font-feature-settings", "font-feature-settings")}}
+
Allows control over advanced typographic features in OpenType fonts.
+
{{cssxref("@font-face/font-variation-settings", "font-variation-settings")}}
+
Allows low-level control over OpenType or TrueType font variations, by specifying the four letter axis names of the features to vary, along with their variation values.
+
{{cssxref("@font-face/src", "src")}}
+
+

Specifies the resource containing the font data. This can be a URL to a remote font file location or the name of a font on the user's computer.

+ +

To provide the browser with a hint as to what format a font resource is — so it can select a suitable one — it is possible to include a format type inside a format() function:

+ +
src: url(ideal-sans-serif.woff) format("woff"),
+     url(basic-sans-serif.ttf) format("truetype");
+ +

The available types are: "woff", "woff2", "truetype", "opentype", "embedded-opentype", and "svg".

+
+
{{cssxref("@font-face/unicode-range", "unicode-range")}}
+
The range of Unicode code points to be used from the font.
+
+ +

Description

+ +

If the local() function is provided, specifying a font name to look for on the user's computer, and the {{Glossary("user agent")}} finds a match, that local font is used. Otherwise, the font resource specified using the url() function is downloaded and used.

+ +

By allowing authors to provide their own fonts, @font-face makes it possible to design content without being limited to the so-called "web-safe" fonts (that is, the fonts which are so common that they're considered to be universally available). The ability to specify the name of a locally-installed font to look for and use makes it possible to customize the font beyond the basics while making it possible to do so without relying on an Internet connection.

+ +

It's common to use both url() and local() together, so that the user's installed copy of the font is used if available, falling back to downloading a copy of the font if it's not found on the user's device.

+ +

The @font-face at-rule may be used not only at the top level of a CSS, but also inside any CSS conditional-group at-rule.

+ +

Font MIME Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
FormatMIME type
TrueTypefont/ttf
OpenTypefont/otf
Web Open Font Formatfont/woff
Web Open Font Format 2font/woff2
+ +

Notes

+ + + +

Formal syntax

+ +
{{csssyntax}}
+ +

Examples

+ +

Specifying a downloadable font

+ +

This example simply specifies a downloadable font to use, applying it to the entire body of the document:

+ +

View the live example

+ +
<html>
+<head>
+  <title>Web Font Sample</title>
+  <style type="text/css" media="screen, print">
+    @font-face {
+      font-family: "Bitstream Vera Serif Bold";
+      src: url("https://mdn.mozillademos.org/files/2468/VeraSeBd.ttf");
+    }
+
+    body { font-family: "Bitstream Vera Serif Bold", serif }
+  </style>
+</head>
+<body>
+  This is Bitstream Vera Serif Bold.
+</body>
+</html>
+
+ +

In this example, the user's local copy of "Helvetica Neue Bold" is used; if the user does not have that font installed (two different names are tried), then the downloadable font named "MgOpenModernaBold.ttf" is used instead:

+ +
@font-face {
+  font-family: MyHelvetica;
+  src: local("Helvetica Neue Bold"),
+       local("HelveticaNeue-Bold"),
+       url(MgOpenModernaBold.ttf);
+  font-weight: bold;
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WOFF2.0', '', 'WOFF2 font format')}}{{Spec2('WOFF2.0')}}Font format specification with new compression algorithm
{{SpecName('WOFF1.0', '', 'WOFF font format')}}{{Spec2('WOFF1.0')}}Font format specification
{{SpecName('CSS3 Fonts', '#font-face-rule', '@font-face')}}{{Spec2('CSS3 Fonts')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("css.at-rules.font-face")}}

+ +

See also

+ + diff --git a/files/my/web/css/css_transitions/index.html b/files/my/web/css/css_transitions/index.html new file mode 100644 index 0000000000..6f134a503b --- /dev/null +++ b/files/my/web/css/css_transitions/index.html @@ -0,0 +1,59 @@ +--- +title: CSS Transitions +slug: Web/CSS/CSS_Transitions +tags: + - CSS + - CSS Transitions + - Overview + - Reference +translation_of: Web/CSS/CSS_Transitions +--- +

{{CSSRef}}

+ +

အသွင်ကူးပြောင်းမှု CSS ကိုကိုကို နျသနျသရငျညြတိကျတဲ့ဂုဏ်သတ္တိများ၏ CSS ကိုတန်ဖိုးများမွားထဲတွင်အကိုကိုကှားတဖြည်းဖြည်းအသွင်ကူးပြောင်းမှု ဖန်တီးပေးနိုင်ပါတယ်ဒါကတော့ CSS ကိုကိုတစ် module တစ်ခုတစ်ခုဖြစ်ပါတယ်။ အဲဒီအသွင်ကူးပြောင်းမှုများ၏အပြုအမူသူတို့ရဲ့ function ကိုကိုအချိန်ကိုက်, ကြာချိန်နှင့်အခြား attribute ကိုတွေသတ်မှတ်ခြင်းကထိန်းချုပ်ထားနိုင်ပါတယ်။

+ +

အညွှန်း

+ +

ဂုဏ်သတ္တိများကို

+ +
+ +
+ +

လမ်းညွှန်များ

+ +
+
CSS ကိုကိုအကူးအပြောင်းကိုအသုံးပြုခြင်း
+
Step-by-step CSS ကိုကိုသုံးပြီးအသွင်ကူးပြောင်းမှုကိုဖန်တီးရန်ဘယ်လိုသင်ခန်းစာ။ ဆောင်းပါးသည်တစြဤဦးချင်းစီကိုကို သက်ဆိုင်ရာ CSS ကိုပိုင်ဆိုင်မှုဖော်ပြထားသည်မွားကိုကိုနှငျ့သူတို့ကတစြ ဦးချင်းစီကတခြားတွေနဲ့အပြန်အလှန်ဘယ်လိုရှင်းပြ ။
+
+ +

အသေးစိတ်ဖော်ပြချက်

+ + + + + + + + + + + + + + + + +
သတ်မှတ်ချက်အဆင့်အတန်းမှတ်ချက်
{{SpecName('CSS3 Transitions')}}{{Spec2('CSS3 Transitions')}}ကနဦးချက်နှင့်အဓိပ္ပါယ်။
+ +

ကိုလည်းကြည့်ပါ

+ + diff --git a/files/my/web/css/index.html b/files/my/web/css/index.html new file mode 100644 index 0000000000..eb5e30fc56 --- /dev/null +++ b/files/my/web/css/index.html @@ -0,0 +1,110 @@ +--- +title: 'CSS: Cascading Style Sheets' +slug: Web/CSS +tags: + - CSS + - Cascading Style Sheets + - Design + - Landing + - Layout + - NeedsTranslation + - Reference + - Style Sheets + - Styles + - Stylesheets + - TopicStub + - 'l10n:priority' +translation_of: Web/CSS +--- +
{{CSSRef}}
+ +

Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML or XML (including XML dialects such as SVG, MathML or {{Glossary("XHTML", "", 1)}}). CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.

+ +

CSS is one of the core languages of the open Web and is standardized across Web browsers according to the W3C specification. Developed in levels, CSS1 is now obsolete, CSS2.1 is a recommendation, and CSS3, now split into smaller modules, is progressing on the standardization track.

+ +
+ + +
+
+

Tutorials

+ +

Our CSS Learning Area features multiple modules that teach CSS from the ground up — no previous knowledge required.

+ +
+
Introduction to CSS
+
This module starts with the basics of how CSS works, including selectors and properties, writing CSS rules, applying CSS to HTML, how to specify length, color, and other units in CSS, cascade and inheritance, box model basics, and debugging CSS.
+
Styling text
+
This module discusses text styling fundamentals, including setting fonts, boldness, italics, line and letter spacing, text drop shadows, and other text properties. This module finishes with applying custom fonts to your page, and styling lists and links.
+
Styling boxes
+
This module looks at styling boxes, one of the fundamental steps towards laying out a web page. In this module we recap the box model, then look at controlling box layouts by setting margins, borders, and padding, custom background colors, images and other features, and fancy features such as drop shadows and filters on boxes.
+
CSS layout
+
At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so you can now dive deep into CSS layout, looking at different display settings, traditional layout methods involving float and positioning, and newfangled layout tools like flexbox.
+
+
+ +
+

Reference

+ + + +

Cookbook

+ +

The CSS layout cookbook aims to bring together recipes for common layout patterns, things you might need to implement in your own sites. In addition to providing code you can use as a starting point in your projects, these recipes highlight the different ways layout specifications can be used, and the choices you can make as a developer.

+ +

Tools for CSS development

+ + + +

Meta bugs

+ +
    +
  • Firefox: {{bug(1323667)}}
  • +
+
+
+
+ +

See also

+ + diff --git a/files/my/web/guide/index.html b/files/my/web/guide/index.html new file mode 100644 index 0000000000..56e0fa9e82 --- /dev/null +++ b/files/my/web/guide/index.html @@ -0,0 +1,67 @@ +--- +title: Web developer guide +slug: Web/Guide +tags: + - Guide + - Landing + - NeedsTranslation + - TopicStub + - Web +translation_of: Web/Guide +--- +

These articles provide how-to information to help you make use of specific technologies and APIs.

+ +
+
+
+
+
+
CSS developer guide
+
Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML
+
Event developer guide
+
Events refers both to a design pattern used for the asynchronous handling of various incidents which occur in the lifetime of a web page and to the naming, characterization, and use of a large number of incidents of different types.
+
Graphics on the Web
+
Modern Web sites and applications often need to present graphics.
+
Guide to Web APIs
+
List all Web APIs and what they are doing
+
HTML developer guide
+
HyperText Markup Language (HTML) is the core language of nearly all Web content. Most of what you see on screen in your browser is described, fundamentally, using HTML.
+
JavaScript
+
JavaScript is the powerful scripting language used to create applications for the Web.
+
Localizations and character encodings
+
Browsers process text as Unicode internally. However, a way of representing characters in terms of bytes (character encoding) is used for transferring text over the network to the browser. The HTML specification recommends the use of the UTF-8 encoding (which can represent all of Unicode) and regardless of the encoding used requires Web content to declare what encoding was used.
+
Mobile Web Development
+
This page provides an overview of some of the main techniques needed to design web sites that work well on mobile devices. If you're looking for information on Mozilla's Firefox OS project, see the Firefox OS page. Or you might be interested in details about Firefox for Android.
+
+ +
+
+
+ +
+
+
Optimization and performance
+
When building modern Web apps and sites, it's important to make your content perform well. That is, to make it work quickly and efficiently. This lets it work effectively both for users of powerful desktop systems as well as for handheld devices with less power.
+
Parsing and serializing XML
+
The Web platform provides the following objects for parsing and serializing XML:
+
SVG-in-OpenType
+
The SVG-in-OpenType work is currently in the hands of the MPEG group. Once we're ready for wider adoption the information from wiki.mozilla.org will be moved here, updated and expanded.
+
The Web Open Font Format (WOFF)
+
WOFF (the Web Open Font Format) is a  web font format developed by Mozilla in concert with Type Supply, LettError, and other organizations. It
+
User experience
+
Making the user experience of your Web site or app a pleasant one for your users is important if you want users to come back and use it again and again. Here you'll find articles that may help you along.
+
Using FormData Objects
+
The FormData object lets you compile a set of key/value pairs to send using XMLHttpRequest. Its primarily intended for use in sending form data, but can be used independently from forms in order to transmit keyed data. The transmitted data is in the same format that the form's submit() method would use to send the data if the form's encoding type were set to "multipart/form-data".
+
Glossary
+
Defines numerous technical terms related to the Web and Internet.
+
+
+
+
+
+ +

See also

+ + diff --git a/files/my/web/http/connection_management_in_http_1.x/index.html b/files/my/web/http/connection_management_in_http_1.x/index.html new file mode 100644 index 0000000000..201f93a64c --- /dev/null +++ b/files/my/web/http/connection_management_in_http_1.x/index.html @@ -0,0 +1,86 @@ +--- +title: Connection management in HTTP/1.x +slug: Web/HTTP/Connection_management_in_HTTP_1.x +translation_of: Web/HTTP/Connection_management_in_HTTP_1.x +--- +
{{HTTPSidebar}}
+ +

การจัดการการเชื่อมต่อเป็นหัวข้อสำคัญใน HTTP: การเปิดและรักษาการเชื่อมต่อส่วนใหญ่มีผลต่อประสิทธิภาพของเว็บไซต์และแอปพลิเคชันเว็บ ใน HTTP / 1.x มีหลายโมเดล: การเชื่อมต่อสั้น ๆ , การเชื่อมต่อแบบถาวรและHTTP pipelining

+ +

HTTP ส่วนใหญ่อาศัย TCP สำหรับโปรโตคอลการขนส่งโดยให้การเชื่อมต่อระหว่างไคลเอนต์และเซิร์ฟเวอร์ ในวัยเด็ก HTTP ใช้แบบจำลองเดียวเพื่อจัดการการเชื่อมต่อดังกล่าว การเชื่อมต่อเหล่านี้มีอายุการใช้งานสั้น: การเชื่อมต่อใหม่ที่สร้างขึ้นทุกครั้งที่จำเป็นต้องส่งคำขอและจะปิดเมื่อได้รับคำตอบ

+ +

โมเดลที่เรียบง่ายนี้มีข้อ จำกัด ด้านประสิทธิภาพโดยธรรมชาติ: การเปิดการเชื่อมต่อ TCP แต่ละครั้งเป็นการดำเนินการที่ใช้ทรัพยากรมาก ต้องแลกเปลี่ยนข้อความหลายข้อความระหว่างไคลเอนต์และเซิร์ฟเวอร์ เวลาในการตอบสนองของเครือข่ายและแบนด์วิดท์มีผลต่อประสิทธิภาพเมื่อคำขอต้องการส่ง หน้าเว็บสมัยใหม่ต้องการคำขอจำนวนมาก (ตั้งแต่หนึ่งโหลขึ้นไป) เพื่อให้บริการข้อมูลตามจำนวนที่ต้องการซึ่งพิสูจน์ได้ว่ารุ่นก่อนหน้านี้ไม่มีประสิทธิภาพ

+ +

รุ่นใหม่กว่าสองรุ่นถูกสร้างขึ้นใน HTTP / 1.1 โมเดลการเชื่อมต่อแบบต่อเนื่องช่วยให้การเชื่อมต่อเปิดระหว่างคำขอที่ต่อเนื่องลดเวลาที่ต้องใช้ในการเปิดการเชื่อมต่อใหม่ รูปแบบการไปป์ไลน์ HTTP ก้าวไปอีกขั้นด้วยการส่งคำขอต่อเนื่องหลายรายการโดยไม่ต้องรอคำตอบช่วยลดเวลาแฝงในเครือข่ายได้มาก

+ +

Compares the performance of the three HTTP/1.x connection models: short-lived connections, persistent connections, and HTTP pipelining.

+ +
+

HTTP / 2 เพิ่มโมเดลเพิ่มเติมสำหรับการจัดการการเชื่อมต่อ

+
+ +

It's important point to note that connection management in HTTP applies to the connection between two consecutive nodes, which is hop-by-hop and not end-to-end. The model used in connections between a client and its first proxy may differ from the model between a proxy and the destination server (or any intermediate proxies). The HTTP headers involved in defining the connection model, like {{HTTPHeader("Connection")}} and {{HTTPHeader("Keep-Alive")}}, are hop-by-hop headers with their values able to be changed by intermediary nodes.

+ +

A related topic is the concept of HTTP connection upgrades, wherein an HTTP/1.1 connection is upgraded to a different protocol, such as TLS/1.0, WebSocket, or even HTTP/2 in cleartext. This protocol upgrade mechanism is documented in more detail elsewhere.

+ +

Short-lived connections

+ +

The original model of HTTP, and the default one in HTTP/1.0, is short-lived connections. Each HTTP request is completed on its own connection; this means a TCP handshake happens before each HTTP request, and these are serialized.

+ +

The TCP handshake itself is time-consuming, but a TCP connection adapts to its load, becoming more efficient with more sustained (or warm) connections. Short-lived connections do not make use of this efficiency feature of TCP, and performance degrades from optimum by persisting to transmit over a new, cold connection.

+ +

This model is the default model used in HTTP/1.0 (if there is no {{HTTPHeader("Connection")}} header, or if its value is set to close). In HTTP/1.1, this model is only used when the {{HTTPHeader("Connection")}} header is sent with a value of close.

+ +
+

Unless dealing with a very old system, which doesn't support a persistent connection, there is no compelling reason to use this model.

+
+ +

Persistent connections

+ +

Short-lived connections have two major hitches: the time taken to establish a new connection is significant, and performance of the underlying TCP connection gets better only when this connection has been in use for some time (warm connection). To ease these problems, the concept of a persistent connection has been designed, even prior to HTTP/1.1. Alternatively this may be called a keep-alive connection.

+ +

A persistent connection is one which remains open for a period of time, and can be reused for several requests, saving the need for a new TCP handshake, and utilizing TCP's performance enhancing capabilities. This connection will not stay open forever: idle connections are closed after some time (a server may use the {{HTTPHeader("Keep-Alive")}} header to specify a minimum time the connection should be kept open).

+ +

Persistent connections also have drawbacks; even when idling they consume server resources, and under heavy load, {{glossary("DoS attack", "DoS attacks")}} can be conducted. In such cases, using non-persistent connections, which are closed as soon as they are idle, can provide better performance.

+ +

HTTP/1.0 connections are not persistent by default. Setting {{HTTPHeader("Connection")}} to anything other than close, usually retry-after, will make them persistent.

+ +

In HTTP/1.1, persistence is the default, and the header is no longer needed (but it is often added as a defensive measure against cases requiring a fallback to HTTP/1.0).

+ +

HTTP pipelining

+ +
+

HTTP pipelining is not activated by default in modern browsers:

+ + + +

For these reasons, pipelining has been superseded by a better algorithm, multiplexing, that is used by HTTP/2.

+
+ +

By default, HTTP requests are issued sequentially. The next request is only issued once the response to the current request has been received. As they are affected by network latencies and bandwidth limitations, this can result in significant delay before the next request is seen by the server.

+ +

Pipelining is the process to send successive requests, over the same persistent connection, without waiting for the answer. This avoids latency of the connection. Theoretically, performance could also be improved if two HTTP requests were to be packed into the same TCP message. The typical MSS (Maximum Segment Size), is big enough to contain several simple requests, although the demand in size of HTTP requests continues to grow.

+ +

Not all types of HTTP requests can be pipelined: only {{glossary("idempotent")}} methods, that is {{HTTPMethod("GET")}}, {{HTTPMethod("HEAD")}}, {{HTTPMethod("PUT")}} and {{HTTPMethod("DELETE")}}, can be replayed safely: should a failure happen, the pipeline content can simply be repeated.

+ +

Today, every HTTP/1.1-compliant proxy and server should support pipelining, though many have limitations in practice: a significant reason no modern browser activates this feature by default.

+ +

Domain sharding

+ +
+

Unless you have a very specific immediate need, don't use this deprecated technique; switch to HTTP/2 instead. In HTTP/2, domain sharding is no longer useful: the HTTP/2 connection is able to handle parallel unprioritized requests very well. Domain sharding is even detrimental to performance. Most HTTP/2 implementations use a technique called connection coalescing to revert eventual domain sharding.

+
+ +

As an HTTP/1.x connection is serializing requests, even without any ordering, it can't be optimal without large enough available bandwidth. As a solution, browsers open several connections to each domain, sending parallel requests. Default was once 2 to 3 connections, but this has now increased to a more common use of 6 parallel connections. There is a risk of triggering DoS protection on the server side if attempting more than this number.

+ +

หากเซิร์ฟเวอร์ต้องการให้เว็บไซต์หรือแอปพลิเคชันตอบสนองเร็วขึ้นเซิร์ฟเวอร์อาจบังคับให้เปิดการเชื่อมต่อเพิ่มเติม ตัวอย่างเช่นแทนที่จะมีทรัพยากรทั้งหมดในโดเมนเดียวกันพูดก็อาจแบ่งมากกว่าหลายโดเมน,www.example.com , , แต่ละโดเมนเหล่านี้แก้ไขไปยังเซิร์ฟเวอร์เดียวกันและเว็บเบราว์เซอร์จะเปิดการเชื่อมต่อ 6 รายการให้กับแต่ละโดเมน(ในตัวอย่างของเราเพิ่มการเชื่อมต่อเป็น 18) เทคนิคนี้เรียกว่าsharding โดเมนwww1.example.comwww2.example.comwww3.example.com

+ +

+ +

สรุป

+ +

การจัดการการเชื่อมต่อที่ได้รับการปรับปรุงช่วยเพิ่มประสิทธิภาพใน HTTP ได้มาก ด้วย HTTP / 1.1 หรือ HTTP / 1.0 การใช้การเชื่อมต่อแบบต่อเนื่องอย่างน้อยก็จนกว่าจะไม่มีการใช้งานจะนำไปสู่ประสิทธิภาพที่ดีที่สุด อย่างไรก็ตามความล้มเหลวของการวางท่อนำไปสู่การออกแบบรูปแบบการจัดการการเชื่อมต่อที่เหนือกว่าซึ่งรวมอยู่ใน HTTP / 2

diff --git a/files/my/web/http/index.html b/files/my/web/http/index.html new file mode 100644 index 0000000000..6e893c3ced --- /dev/null +++ b/files/my/web/http/index.html @@ -0,0 +1,90 @@ +--- +title: HTTP +slug: Web/HTTP +tags: + - HTTP + - Hypertext + - NeedsTranslation + - Reference + - TCP/IP + - TopicStub + - Web + - Web Development + - 'l10n:priority' +translation_of: Web/HTTP +--- +
{{HTTPSidebar}}
+ +

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes. HTTP follows a classical client-server model, with a client opening a connection to make a request, then waiting until it receives a response. HTTP is a stateless protocol, meaning that the server does not keep any data (state) between two requests. Though often based on a TCP/IP layer, it can be used on any reliable transport layer, that is, a protocol that doesn't lose messages silently like UDP does. RUDP — the reliable update of UDP — is a suitable alternative.

+ +
+
+

Tutorials

+ +

Learn how to use HTTP with guides and tutorials.

+ +
+
Overview of HTTP
+
The basic features of the client-server protocol: what it can do and its intended uses.
+
HTTP Cache
+
Caching is very important for fast Web sites. This article describes different methods of caching and how to use HTTP Headers to control them.
+
HTTP Cookies
+
How cookies work is defined by RFC 6265. When serving an HTTP request, a server can send a Set-Cookie HTTP header with the response. The client then returns the cookie's value with every request to the same server in the form of a Cookie request header. The cookie can also be set to expire on a certain date, or restricted to a specific domain and path.
+
Cross-Origin Resource Sharing (CORS)
+
Cross-site HTTP requests are HTTP requests for resources from a different domain than the domain of the resource making the request. For instance, an HTML page from Domain A (http://domaina.example/) makes a request for an image on Domain B (http://domainb.foo/image.jpg) via the img element. Web pages today very commonly load cross-site resources, including CSS stylesheets, images, scripts, and other resources. CORS allows web developers to control how their site reacts to cross-site requests.
+
+ +
+
Evolution of HTTP
+
A brief description of the changes between the early versions of HTTP, to the modern HTTP/2, the emergent HTTP/3 and beyond.
+
Mozilla web security guidelines
+
A collection of tips to help operational teams with creating secure web applications.
+
+ +
+
HTTP Messages
+
Describes the type and structure of the different kind of messages of HTTP/1.x and HTTP/2.
+
A typical HTTP session
+
Shows and explains the flow of a usual HTTP session.
+
Connection management in HTTP/1.x
+
Describes the three connection management models available in HTTP/1.x, their strengths, and their weaknesses.
+
+
+ +
+

Reference

+ +

Browse through detailed HTTP reference documentation.

+ +
+
HTTP Headers
+
HTTP message headers are used to describe a resource, or the behavior of the server or the client. Custom proprietary headers can be added using the X- prefix; others in an IANA registry, whose original content was defined in RFC 4229. IANA also maintains a registry of proposed new HTTP message headers.
+
HTTP Request Methods
+
The different operations that can be done with HTTP: {{HTTPMethod("GET")}}, {{HTTPMethod("POST")}}, and also less common requests like {{HTTPMethod("OPTIONS")}}, {{HTTPMethod("DELETE")}}, or {{HTTPMethod("TRACE")}}.
+
HTTP Status Response Codes
+
HTTP response codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: informational responses, successful responses, redirections, client errors, and servers errors.
+
+ +
+
CSP directives
+
The {{HTTPHeader("Content-Security-Policy")}} response header fields allows web site administrators to control resources the user agent is allowed to load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints.
+
+ +

Tools & resources

+ +

Helpful tools and resources for understanding and debugging HTTP.

+ +
+
Firefox Developer Tools
+
Network monitor
+
Mozilla Observatory
+
+

A project designed to help developers, system administrators, and security professionals configure their sites safely and securely.

+
+
RedBot
+
Tools to check your cache-related headers
+
How Browsers Work
+
A very comprehensive article on browser internals and request flow through HTTP protocol. A MUST-READ for any web developer.
+
+
+
diff --git a/files/my/web/index.html b/files/my/web/index.html new file mode 100644 index 0000000000..3b55338e60 --- /dev/null +++ b/files/my/web/index.html @@ -0,0 +1,90 @@ +--- +title: Web developers နင့္ နည္းပညာ မျာ +slug: Web +tags: + - Landing + - NeedsTranslation + - TopicStub + - Web +translation_of: Web +--- +

The open Web presents incredible opportunities for developers. To take full advantage of these technologies, you need to know how to use them. Below you'll find the links to MDN's documentation on Web technologies.

+ +

 

+ +

လွတ်လပ်စ

+ +

 

+ +

 

+ +
+
+

Web နည်းပညာများ

+ +

အခြေခံ

+ +
+
HTML
+
၀ဘ်စာမျက်နာတစ်ခုတွင် ပါ၀င်သောအကြောင်းအရာများအား စနစ်ကျတဲ့ ဖွဲ့စည်းပုံ ကို သက်မတ်ရန် အသုံးပြုသောနည်းပညာ တစ်ခုဖြစ်ပါသည။
+
CSS
+
 ၀ဘ်စာမျက်နာပါအကြောင်းအရာများရဲ့  အသွင်အပြင်ကို ဖော်ပြဖို့အတွက်သုံးသည်။
+
+ +

Scripting

+ +
+
JavaScript
+
JavaScript is the programming language that runs in the browser, which is used to build advanced user interactive Web sites and applications.
+
Web APIs
+
Reference material for each of the individual APIs that comprise the Web's powerful scriptability, including the DOM and all of the related APIs and interfaces you can use to build Web content and apps. + +
+
+ +

Graphics

+ +
+
SVG
+
Scalable Vector Graphics let you describe images as sets of vectors (lines) and shapes in order to allow them to scale smoothly regardless of the size at which they're drawn.
+
WebGL
+
WebGL brings 3D graphics to the Web by introducing an API that closely conforms to OpenGL ES 2.0, and which can be used in HTML {{HTMLElement("canvas")}} elements.
+
+ +

Other

+ +
+
MathML
+
The Mathematical Markup Language makes it possible to display complex mathematical equations and syntax.
+
+
+ +
+

Documentation by type

+ +
+
Web Developer Guide
+
The Web Developer Guide provides useful how-to content to help you actually use Web technologies to do what you want or need to do.
+
Tutorials for Web developers
+
A list of tutorials to take you step-by-step through learning APIs, technologies, or broad topic areas.
+
References
+
This page will offer links to all reference information on MDN, but for now use one of the technology links in the left section.
+
+ +

Other topics

+ +
+
Developing Web applications
+
Documentation for Web application developers; Web apps are true write-once, deploy anywhere apps for mobile, desktop, and Firefox OS.
+
Accessibility
+
Accessibility in Web development means enabling as many people as possible to use Web sites, even when those people's abilities are limited in some way. Here we provide information on developing Web content to be accessible.
+
Security
+
Ensuring that your Web site or open Web app is secure is critical.
+
+
+
+ +

View All...

diff --git a/files/my/web/javascript/index.html b/files/my/web/javascript/index.html new file mode 100644 index 0000000000..d26ea34fb6 --- /dev/null +++ b/files/my/web/javascript/index.html @@ -0,0 +1,104 @@ +--- +title: JavaScript +slug: Web/JavaScript +tags: + - JavaScript + - Landing + - NeedsTranslation + - TopicStub +translation_of: Web/JavaScript +--- +
{{JsSidebar}}
+ +

JavaScript® (အတိုကောက် JS) ဆိုတာ   first-class functions  နှင့်တည်ဆောက်ထား တဲ့a  lightweight, interpreted, object-oriented language တစ်ခုဖြစ်ပါတယ်။အများက သိတာကတော့ web pages တွေအတွက် browser ကိုအခြေ ခံထားတဲ့ scripting language တစ်ခုအနေနဲ့သိကြတယ် ဒါပေမဲ့ browser ကိုအခြေခံ မထားတဲ့ နေရာ တွေဖြစ်တဲ့  node.js ဒါမှမဟုတ်  Apache CouchDB တွေမှာလဲအသုံးပြု ပါတယ်. Javascript ဟာ  prototype-based, multi-paradigm scripting language ဖြစ်ပါတယ်၊ ဆိုလိုတာက dynamic ဖြစ်သလို object-oriented, imperative, and functional programming ရေးသားနည်းပုံစံနဲ့လည်း ထောက်ပံပေးပါတယ်။ အသေးစိတ်ကိုတော့ JavaScript အကြောင်း ပိုမို ဖတ်ရှုကြည့်ပါ။

+ +

JavaScript စံသတ်မှတ်ချက်ကို ECMAScript လို့ခေါ်ပါတယ်။ ၂၀၁၂ မှာ modern browsers တွေအကုန်လုံးက ECMAScript 5.1 ကို အပြည့်အဝ support ပေးနေပါပြီ။ Browsers အဟောင်းတွေက အနည်းဆုံး ECMAScript 3 ကို support ပေးပါတယ်။ ဇွန်လ ၁၇ ရက် ၂၀၁၅ မှာ ခြောက်ကြိမ်မြောက် ECMAScript ကို ကြေငြာပြဌာန်းလိုက်ပါတယ်။ အဲ့ဒီ့ version ကို ECMAScript 2015 လို့တရားဝင်ခေါ်ပါတယ်၊ ဒါပေမယ့်လည်း ECMAScript 6 ဒါမှမဟုတ် ES6 ဆိုပြီးလည်းခေါ်ပါတယ်။

+ +

 ဒီဝက်စာမျက်နှာမှာတော့ JavaScript အကြောင်းကိုပဲ ပြောပြသွားမှာဖြစ်ပါတယ်။Web Pages နဲ့ ဆက်စပ်ပြီးသုံးတဲ့ ဒါမှမဟုတ် တစ်ခြားသော Host Environment နဲ့ စပ်ဆက်ပြီးသုံးတဲ့ အကြောင်းကို ပြောမှ မဟုတ်ပါဘူး။. Web pages နဲ့  စပ်ဆက်ပြီး အသုံးပြုတဲ့ {{Glossary("API","APIs")}}  ကို လေ့လာချင်တဲ့ဆိုရင်တော့ Web APIs နဲ့  DOM မှာ သွားရောက် လေ့လာလို့ရပါတယ်။

+ +

JavaScript ကို Java programming language နဲ့ မတူဘူးဆိုတာ သိထားဖို့လိုပါမယ်။ Java ဆိုတာ U.S. နဲ့ အခြားသောနိုင်ငံတွေမှာ Oracle က မူပိုင်တင်ထားပါတယ်။

+ +
+
+

နည်းပြသင်ခန်းစာများ

+ +

ကျွန်တော်တို့ရဲ့ နည်းပြသင်ခန်းစာများနဲ့ လေ့ကျင့်ခန်းများမှတစ်ဆင့် JavaScript နဲ့ဘယ်လို program လုပ်မလဲဆိုတာလေ့လာပါ။

+ +

နိဒါန်း

+ +
+
JavaScript လမ်းညွှန်
+
သင်က JavaScript ကိုအခုမှစတင်လေ့လာမယ့်သူဆိုရင် ဒီလမ်းညွှန်ကသင့်ကိုအထောက်အကူပြုပါလိမ့်မယ်။ 
+
+
JavaScript နည်းပညာချုံငုံသုံးသပ်ချက်
+
Web browser နဲ့ JavaScript landscape မိတ်ဆက်။
+
Object Oriented JavaScript မိတ်ဆက်
+
Introduction to the concepts of object oriented programming in JavaScript.
+
+ +

Intermediate

+ +
+
A re-introduction to JavaScript
+
An overview for those who think they know about JavaScript.
+
+ +
+
JavaScript data structures
+
Overview of available data structures in JavaScript.
+
Equality comparisons and sameness
+
JavaScript provides three different value-comparison operations: strict equality using ===, loose equality using ==, and the {{jsxref("Global_Objects/Object/is", "Object.is()")}} method.
+
+ +

Advanced

+ +
+
Inheritance and the prototype chain
+
Explanation of the widely misunderstood and under-estimated prototype-based inheritance.
+
Strict mode
+
A restricted variant of JavaScript.
+
JavaScript typed arrays
+
JavaScript typed arrays provide a mechanism for accessing raw binary data.
+
Memory Management
+
Memory life cycle and garbage collection in JavaScript.
+
+
+ +
+

အညွှန်း

+ +

Browse the complete JavaScript reference documentation. 

+ +
+
Standard objects
+
Get to know standard built-in objects Array, Boolean, Date, Error, Function, JSON, Math, Number, Object, RegExp, StringMap, Set, WeakMap, WeakSet, and others.
+
Expressions and operators
+
Learn more about the behavior of JavaScript's operators instanceof, typeof, new, this, the operator precedence, and more.
+
Statements and declarations
+
Learn how do-while, for-in, for-of, try-catch, let, var, const, if-else, switch, and more JavaScript statements and keywords work.
+
Functions
+
Learn how to work with JavaS functions to develop your applications.
+
+ +

Tools & resources

+ +

Helpful tools while writing and debugging your JavaScript code.

+ +
+
Firefox Developer Tools
+
Scratchpad, Web Console, JavaScript Profiler, Debugger, and more.
+
Firebug
+
Edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
+
JavaScript Shells
+
A JavaScript shell allows you to quickly test snippets of JavaScript code.
+
TogetherJS
+
+

Collaboration made easy.

+
+
Stack Overflow
+
Stack Overflow questions tagged with "JavaScript".
+
JavaScript versions and release notes
+
Browse JavaScript's feature history and implementation status.
+
+
+
diff --git a/files/my/web/javascript/reference/index.html b/files/my/web/javascript/reference/index.html new file mode 100644 index 0000000000..1345585f85 --- /dev/null +++ b/files/my/web/javascript/reference/index.html @@ -0,0 +1,312 @@ +--- +title: JavaScript reference +slug: Web/JavaScript/Reference +tags: + - Code + - ECMAScript + - ECMAScript6 + - ES6 + - JS + - JavaScript + - Landing page + - NeedsTranslation + - Reference + - TopicStub + - es + - 'l10n:priority' + - programming +translation_of: Web/JavaScript/Reference +--- +
{{JsSidebar}}
+ +

This part of the JavaScript section on MDN serves as a repository of facts about the JavaScript language. Read more about this reference.

+ +

Built-ins

+ +

JavaScript standard built-in objects, along with their methods and properties.

+ + + + + + + + + +

Statements

+ +

JavaScript statements and declarations

+ + + + + +

Expressions and operators

+ +

JavaScript expressions and operators

+ +
+ + + + + +
+ +

Functions

+ +

This chapter documents how to work with JavaScript functions to develop your applications.

+ + + +

Additional reference pages

+ + diff --git a/files/my/web/javascript/reference/statements/function_star_/index.html b/files/my/web/javascript/reference/statements/function_star_/index.html new file mode 100644 index 0000000000..414d5f4d63 --- /dev/null +++ b/files/my/web/javascript/reference/statements/function_star_/index.html @@ -0,0 +1,252 @@ +--- +title: function* +slug: Web/JavaScript/Reference/Statements/function* +translation_of: Web/JavaScript/Reference/Statements/function* +--- +
{{jsSidebar("Statements")}}
+ +

The function* declaration (function keyword followed by an asterisk) defines a generator function, which returns a {{jsxref("Global_Objects/Generator","Generator")}} object.

+ +
{{EmbedInteractiveExample("pages/js/statement-functionasterisk.html")}}
+ + + +

You can also define generator functions using the {{jsxref("GeneratorFunction")}} constructor, or the function expression syntax.

+ +

Syntax

+ +
function* name([param[, param[, ... param]]]) {
+   statements
+}
+
+ +
+
name
+
The function name.
+
param {{optional_inline}}
+
The name of a formal parameter for the function.
+
statements
+
The statements comprising the body of the function.
+
+ +

Description

+ +

Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.

+ +

Generators in JavaScript -- especially when combined with Promises -- are a very powerful tool for asynchronous programming as they mitigate -- if not entirely eliminate -- the problems with callbacks, such as Callback Hell and Inversion of Control. However, an even simpler solution to these problems can be achieved with {{jsxref("Statements/async_function", "async functions")}}.

+ +

Calling a generator function does not execute its body immediately; an iterator object for the function is returned instead. When the iterator's next() method is called, the generator function's body is executed until the first {{jsxref("Operators/yield", "yield")}} expression, which specifies the value to be returned from the iterator or, with {{jsxref("Operators/yield*", "yield*")}}, delegates to another generator function. The next() method returns an object with a value property containing the yielded value and a done property which indicates whether the generator has yielded its last value, as a boolean. Calling the next() method with an argument will resume the generator function execution, replacing the yield expression where an execution was paused with the argument from next().

+ +

A return statement in a generator, when executed, will make the generator finish (i.e. the done property of the object returned by it will be set to true). If a value is returned, it will be set as the value property of the object returned by the generator.
+ Much like a return statement, an error is thrown inside the generator will make the generator finished -- unless caught within the generator's body.
+ When a generator is finished, subsequent next() calls will not execute any of that generator's code, they will just return an object of this form: {value: undefined, done: true}.

+ +

Examples

+ +

Simple example

+ +
function* idMaker() {
+  var index = 0;
+  while (true)
+    yield index++;
+}
+
+var gen = idMaker();
+
+console.log(gen.next().value); // 0
+console.log(gen.next().value); // 1
+console.log(gen.next().value); // 2
+console.log(gen.next().value); // 3
+// ...
+ +

Example with yield*

+ +
function* anotherGenerator(i) {
+  yield i + 1;
+  yield i + 2;
+  yield i + 3;
+}
+
+function* generator(i) {
+  yield i;
+  yield* anotherGenerator(i);
+  yield i + 10;
+}
+
+var gen = generator(10);
+
+console.log(gen.next().value); // 10
+console.log(gen.next().value); // 11
+console.log(gen.next().value); // 12
+console.log(gen.next().value); // 13
+console.log(gen.next().value); // 20
+
+ +

Passing arguments into Generators

+ +
function* logGenerator() {
+  console.log(0);
+  console.log(1, yield);
+  console.log(2, yield);
+  console.log(3, yield);
+}
+
+var gen = logGenerator();
+
+// the first call of next executes from the start of the function
+// until the first yield statement
+gen.next();             // 0
+gen.next('pretzel');    // 1 pretzel
+gen.next('california'); // 2 california
+gen.next('mayonnaise'); // 3 mayonnaise
+
+ +

Return statement in a generator

+ +
function* yieldAndReturn() {
+  yield "Y";
+  return "R";
+  yield "unreachable";
+}
+
+var gen = yieldAndReturn()
+console.log(gen.next()); // { value: "Y", done: false }
+console.log(gen.next()); // { value: "R", done: true }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as an object property

+ +
const someObj = {
+  *generator () {
+    yield 'a';
+    yield 'b';
+  }
+}
+
+const gen = someObj.generator()
+
+console.log(gen.next()); // { value: 'a', done: false }
+console.log(gen.next()); // { value: 'b', done: false }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as an object method

+ +
class Foo {
+  *generator () {
+    yield 1;
+    yield 2;
+    yield 3;
+  }
+}
+
+const f = new Foo ();
+const gen = f.generator();
+
+console.log(gen.next()); // { value: 1, done: false }
+console.log(gen.next()); // { value: 2, done: false }
+console.log(gen.next()); // { value: 3, done: false }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as a computed property

+ +
class Foo {
+  *[Symbol.iterator] () {
+    yield 1;
+    yield 2;
+  }
+}
+
+const SomeObj = {
+  *[Symbol.iterator] () {
+    yield 'a';
+    yield 'b';
+  }
+}
+
+console.log(Array.from(new Foo)); // [ 1, 2 ]
+console.log(Array.from(SomeObj)); // [ 'a', 'b' ]
+
+ +

Generators are not constructable

+ +
function* f() {}
+var obj = new f; // throws "TypeError: f is not a constructor
+
+ +

Generator defined in an expression

+ +
const foo = function* () {
+  yield 10;
+  yield 20;
+};
+
+const bar = foo();
+console.log(bar.next()); // {value: 10, done: false}
+ +

Generator example

+ +
function* powers(n){
+     //endless loop to generate
+     for(let current =n;; current *= n){
+         yield current;
+     }
+}
+
+for(let power of powers(2)){
+     //controlling generator
+     if(power > 32) break;
+     console.log(power)
+           //2
+          //4
+         //8
+        //16
+       //32
+}
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-generator-function-definitions', 'function*')}}
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.statements.generator_function")}}

+
+ +

See also

+ + diff --git a/files/my/web/javascript/reference/statements/index.html b/files/my/web/javascript/reference/statements/index.html new file mode 100644 index 0000000000..b5f4f3d5e0 --- /dev/null +++ b/files/my/web/javascript/reference/statements/index.html @@ -0,0 +1,130 @@ +--- +title: Statements and declarations +slug: Web/JavaScript/Reference/Statements +tags: + - JavaScript + - Landing page + - NeedsTranslation + - Reference + - TopicStub + - statements +translation_of: Web/JavaScript/Reference/Statements +--- +
{{jsSidebar("Statements")}}
+ +

JavaScript applications consist of statements with an appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon. This isn't a keyword, but a group of keywords.

+ +

Statements and declarations by category

+ +

For an alphabetical listing see the sidebar on the left.

+ +

Control flow

+ +
+
{{jsxref("Statements/block", "Block")}}
+
A block statement is used to group zero or more statements. The block is delimited by a pair of curly brackets.
+
{{jsxref("Statements/break", "break")}}
+
Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.
+
{{jsxref("Statements/continue", "continue")}}
+
Terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.
+
{{jsxref("Statements/Empty", "Empty")}}
+
An empty statement is used to provide no statement, although the JavaScript syntax would expect one.
+
{{jsxref("Statements/if...else", "if...else")}}
+
Executes a statement if a specified condition is true. If the condition is false, another statement can be executed.
+
{{jsxref("Statements/switch", "switch")}}
+
Evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case.
+
{{jsxref("Statements/throw", "throw")}}
+
Throws a user-defined exception.
+
{{jsxref("Statements/try...catch", "try...catch")}}
+
Marks a block of statements to try, and specifies a response, should an exception be thrown.
+
+ +

Declarations

+ +
+
{{jsxref("Statements/var", "var")}}
+
Declares a variable, optionally initializing it to a value.
+
{{jsxref("Statements/let", "let")}}
+
Declares a block scope local variable, optionally initializing it to a value.
+
{{jsxref("Statements/const", "const")}}
+
Declares a read-only named constant.
+
+ +

Functions and classes

+ +
+
{{jsxref("Statements/function", "function")}}
+
Declares a function with the specified parameters.
+
{{jsxref("Statements/function*", "function*")}}
+
Generator Functions enable writing iterators more easily.
+
{{jsxref("Statements/async_function", "async function")}}
+
Declares an async function with the specified parameters.
+
{{jsxref("Statements/return", "return")}}
+
Specifies the value to be returned by a function.
+
{{jsxref("Statements/class", "class")}}
+
Declares a class.
+
+ +

Iterations

+ +
+
{{jsxref("Statements/do...while", "do...while")}}
+
Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
+
{{jsxref("Statements/for", "for")}}
+
Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
+
{{jsxref("Statements/for_each...in", "for each...in")}} 
+
Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.
+
{{jsxref("Statements/for...in", "for...in")}}
+
Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
+
{{jsxref("Statements/for...of", "for...of")}}
+
Iterates over iterable objects (including {{jsxref("Global_Objects/Array","arrays","","true")}}, array-like objects, iterators and generators), invoking a custom iteration hook with statements to be executed for the value of each distinct property.
+
{{jsxref("Statements/for-await...of", "for await...of")}}
+
Iterates over async iterable objects, array-like objects, iterators and generators, invoking a custom iteration hook with statements to be executed for the value of each distinct property.
+
{{jsxref("Statements/while", "while")}}
+
Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
+
+ +

Others

+ +
+
{{jsxref("Statements/debugger", "debugger")}}
+
Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.
+
{{jsxref("Statements/export", "export")}}
+
Used to export functions to make them available for imports in external modules, and other scripts.
+
{{jsxref("Statements/import", "import")}}
+
Used to import functions exported from an external module, another script.
+
import.meta
+
An object exposing context-specific metadata to a JavaScript module.
+
{{jsxref("Statements/label", "label")}}
+
Provides a statement with an identifier that you can refer to using a break or continue statement.
+
+ +
+
{{jsxref("Statements/with", "with")}} 
+
Extends the scope chain for a statement.
+
+ +

Specifications

+ + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-ecmascript-language-statements-and-declarations', 'ECMAScript Language: Statements and Declarations')}}
+ +

Browser compatibility

+ + + +

{{Compat("javascript.statements")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf